I have trouble with parsing a logfile… Here is a logfile sample (in real live there are bash color codes included):
foo completely unintresting line bar
foo [INFO] [#############] bar
foo [INFO] [#######______] bar
I need the parts “[#############]” and “[#######__]”. To get these information I drop the unintresting lines with:
CMD_TAIL=`tail -n 3 server.log | sed -r "s/\x1B\[([0-9]{1,3}((;[0-9]{1,3})*)?)?[m|K]//g" | grep -E '\[INFO\] \[[#_]+\]'`
But if I “walk” the CMD_TAIL I get this (whitespace replaced by newline):
1: foo :2
1: [INFO] :2
1: [#############] :2
1: bar :2
...
How do I get the complete line so I can extract the needed information?
In case you’re in a bash-like shell, try setting the internal field separator to newline before your loop: