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
By default, the record separator is the newline character, defining a record to be a single line of text. You can use a different character by changing the built-in variable RS. The value of RS is a string that says how to separate records; the default value is \n
, the string containing just a newline character.
awk 'BEGIN { RS = "/" } ; { print $0 }' BBS-list