journalctl -b showed me log like this:
something something somethng
aaa: 0x00000111 bbb: 0x00000222 ccc: 0x00000333 ddd: 0x00000444
something something somethng
How to get value of parameter 'ccc'?
For example:
journalctl -b | awk '/ccc:/{print $1}'
showed first word, but I need to get first word after 'ccc':
0x00000333
Using sed
:
$ echo "aaa: 0x00000111 bbb: 0x00000222 ccc: 0x00000333 ddd: 0x00000444"|sed 's/.*ccc: \([^ ]*\).*/\1/g'
0x00000333
If you really want to use awk
:
$ echo "aaa: 0x00000111 bbb: 0x00000222 ccc: 0x00000333 ddd: 0x00000444"|awk '/ccc:/{s=$0; gsub(".*ccc: ", "", s); gsub(" .*$", "", s); print s}'
0x00000333
This line will give your the value if the key is ccc
:
journalctl -b|grep -oP 'ccc: \K[^ :]*'
e.g.
kent$ grep -oP 'ccc: \K[^: ]*'<<<"aaa: 0x00000111 bbb: 0x00000222 ccc: 0x00000333 ddd: adfa"
0x00000333
User contributions licensed under CC BY-SA 3.0