我有一份记录单,有这样的条目:
{"@timestamp":"2024-02-28T10:21:51.939Z", "log.level":"info", "msg": "done"}
我想把这支 j子变成这样的东西:
2024-02-28T10:21:51.939Z - info - done
This is the output I get from my shell commands:
$ msg= {"@timestamp":"2024-02-28T10:21:51.939Z", "log.level":"info", "msg": "done"}
$ echo $msg | jq -r "(.["log.level"])"
jq: error: syntax error, unexpected INVALID_CHARACTER (Unix shell quoting issues?) at <top-level>, line 1:
"(.["log.level"])"
jq: 1 compile error
$ echo $msg | jq -r "(.msg)"
done
$ echo $msg | jq -r "(.["@timestamp"])"
jq: error: syntax error, unexpected INVALID_CHARACTER (Unix shell quoting issues?) at <top-level>, line 1:
"(.["@timestamp"])"
jq: 1 compile error
$ echo $msg | jq -r "(.@timestamp)"
jq: error: syntax error, unexpected QQSTRING_INTERP_END, expecting QQSTRING_START (Unix shell quoting issues?) at <top-level>, line 1:
"(.@timestamp)"
jq: error: try .["field"] instead of .field for unusually named fields at <top-level>, line 1:
"(.@timestamp)"
jq: 2 compile errors
I m在乌班图使用巴什。 jq-1.6