cat 2.txt | ./jq '{(.id): .custom}'
以上命令输出:
{
"1": {
"results": "Success"
}
}
{
"2": {
"input method": "touch",
"from": "Prescription Center",
}
}
{
"3": {
"entry point": "|All"
}
}
预期输出:
我想将每个对象打印/保存到一行中。
cat 2.txt | ./jq '{(.id): .custom}'
{ "1": { "results": "Success" } }
{ "2": { "input method": "touch", "from": "Prescription Center" } }
{ "3": { "entry point": "|All" } }
能否在shell脚本中实现?
cat 2.txt | ./jq -c '{(.id): .custom}'
吗?(参考链接:http://stedolan.github.io/jq/manual/) - Prixjq
,你为什么在本地目录中有它?我对那个工具很感兴趣。 - Alfesudo apt-get install jq
- glenn jackmanapt-file
没有显示出来,但是apt-get
可以安装它。我猜我得学习更多关于这两个包管理工具的知识。谢谢! - Alfeapt-file update
就解决了问题;现在apt-file list
也显示了jq
包。看起来是在最近几个月/年出现的(在我上次进行apt-file update
之前)。 - Alfe