4 ms·
The first line they start with is utter nonsense. find -print0 will not produce lines, but records (or strings) separated by NUL. But grep is a tool working wit
by usr1106 2y ago
The first line they start with is utter nonsense. find -print0 will not produce lines, but records (or strings) separated by NUL. But grep is a tool working with lines (separated by LF). No mystery that it cannot work.
Using -print0 is necessary if you have filenames containing LF chars. Otherwise just use -print and grep and everything should be fine.
Now how do we handle NUL separated records? That required a bit of thinking, the Unix world is based so much on lines. Without extensive testing the following awk program seems to work:
BEGIN { RS = "\0" }
$0 ~ regexp
Call with
awk -v 'regexp=what I search for'
In their script that would be
awk -v "regexp=$1"
Edit: Credits for s/whitespace/LF chars/ go to user hnfong