【发布时间】:2015-09-16 11:20:48
【问题描述】:
如果我运行它,我有一个 curl 命令,输出如下,
{
"page" : 1,
"records" : 1,
"total" : 1,
"rows" : [ {
"automated" : true,
"collectionProtocol" : "MagBead Standard Seq v2",
"comments" : "",
"copy" : false,
"createdBy" : "stest",
"custom1" : "User Defined Field 1=",
"custom2" : "User Defined Field 2=",
"custom3" : "User Defined Field 3=",
"custom4" : "User Defined Field 4=",
"custom5" : "User Defined Field 5=",
"custom6" : "User Defined Field 6=",
"description" : null,
"editable" : false,
"expanded" : false,
"groupName" : "99111",
"groupNames" : [ "all" ],
"inputCount" : 1,
"instrumentId" : 1,
"instrumentName" : "42223",
"jobId" : 11111,
"jobStatus" : "In Progress",
"leaf" : true,
"modifiedBy" : null,
"name" : "Copy_of_Test_Running2"
} ]
}
我只想提取 jobId 的值。 这个输出将是
11111
如果有多行则有多个jobId
11111
11112
11113
我只想在 while 循环中提取 jobId 和 process。 如下图,
while read job; do
echo $job
done < < (curl command)
我想在另一个命令中使用该作业 ID。 卷曲结果可能是多个。
您是否有想法轻松提取 curl 输出并进行 while 或 for 循环?
【问题讨论】:
-
使用 jq:stedolan.github.io/jq
-
多行的格式是什么?
-
@Mircea 谢谢 jq 太棒了