Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multicharacter delimiter cut

Tags:

linux

bash

My file looks like:

19-04-05 08:45:22,643: INFO  [ByrioThread] [] kks.connectorLog: Very important information

I want to cut it using a two character delimiter ": ", but with field definition "field 2 and all next". This would be a cut command as:

cut -f2- -d': '

so the output would be:

INFO  [ByrioThread] [] kks.connectorLog: Very important information

however cut does not support multicharacter delimiter. Therefore answer given here How to use cut with multiple character delimiter? unix with awk does not work.

Any help appreciated!

like image 594
pawel_j Avatar asked Nov 01 '25 13:11

pawel_j


1 Answers

This grep might work for you:

grep -Po ': \K.*' file

Or a pure bash solution using parameter expansion:

while IFS= read -r line; do
   printf '%s\n' "${line#*: }"
done < file
like image 60
mickp Avatar answered Nov 03 '25 06:11

mickp



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!