I have a NUL delimited output coming from the following command :
some commands | grep -i -c -w -Z 'some regex'
The output consists of records of the format :
[file name]\0[pattern count]\0
I want to use text manipulation tools, such as sed/awk, to change the records to the following format :
[file name]:[pattern count]\0
But it seems that sed/awk usually handles only records delimited by the "newline" character. I would like to know that how sed/awk could be used to achieve my purpose, or if sed/awk could not handle such case what other Linux tool should I use.
Thanks for any suggestion.
Lawrence
grep -c -Z
would only place a NUL character after[file name]
but would place a "newline" character after[pattern count]
. I now choose not to use thegrep -Z
option but TejasP's answer is still helpful for me to parse NUL delimited files using awk in the future. Thanks all. – user1129812 Feb 7 '12 at 6:03