Reputation: 1
With grep
, you have a --null-data
option
-z, --null-data a data line ends in 0 byte, not newline
In this way a line is a string ending with a null character, instead of a newline. Does awk
have a similar option?
Upvotes: 3
Views: 294
Reputation: 17346
You can set RS
(the record separator) to change how awk
views lines. This would be set in a similar manner to the field separator FS
. Depending on the version of awk
you are using you may be able to set this to NULL.
For example,
awk '{ print $0 }' RS="\0" file
Note that this may not be portable if you are not using the GNU awk implementation.
Upvotes: 5
Reputation: 185025
With awk, you can use printf
:
awk '/regex/{printf("%s\n\0", $0)}'
Upvotes: 0