I have a logfile with entries like this:
{"@timestamp":"2024-02-28T10:21:51.939Z", "log.level":"info", "msg": "done"}
I want to convert this json into something like this:
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 using bash on Ubuntu. jq-1.6