On 07/18/11 23:12, [email protected] wrote:
> Hi,
>
> the manual page of grep mentioned the following:
>
> -Z, --null
> Output a zero byte (the ASCII NUL character) instead of the
> character that normally follows a file name. For example, grep -lZ outputs a
> zero byte
> after each file name instead of the usual newline. This option
> makes the output unambiguous, even in the presence of file names containing
> unusual
> characters like newlines. This option can be used with
> commands like find -print0, perl -0, sort -z, and xargs -0 to process
> arbitrary file names,
> even those that contain newline characters.
>
> for me (as a non-native English speak ;) ) this means:
>
> Replace a newlie after a filename with a zero-byte.
>
> So when doing
>
> find /tmp | grep -Z tmp | xargs -0 md5sum
>
> it should work comparable to
>
> find /tmp -print0 | xargs -0 md5sum
>
> but for me it does not.
>
> If my logic is not complete nonsense I dont understand the second
> part of the text of the manual page:
>
>
> This option can be used with commands like find -print0, perl
> -0, sort -z, and xargs -0 to process arbitrary file names,
> even those that contain newline characters.
>
>
> If I would do
>
>
> find /tmp -print0 | grep -Z tmp | xargs -0 md5sum
>
> there are no newlines which could be printed "instead of the character that
> normally follows a file name. For example, grep -lZ outputs a zero byte
> after each file name instead of the usual newline. "....
This took me a few minutes to actually figure out exactly what -Z in
supposed to do. But I *think* it does exactly this. Whatever character
comes directly after the filename is replaces by NUL. As you can see in
my example below, the character that normally follows a filename is ':'
(a colon), but with the -Z option, the colon is replace with NUL, this
no 'character' follows it.
~/joe/sullivan $ grep -Z document ./*
./core.js$(document).ready(function() {
./core.js $(document).pngFix();
./core.js var map = new
google.maps.Map(document.getElementById("map_of_region"), myOptions);
~/joe/sullivan $ grep document ./*
./core.js:$(document).ready(function() {
./core.js: $(document).pngFix();
./core.js: var map = new
google.maps.Map(document.getElementById("map_of_region"), myOptions);
But please do correct me if I'm wrong.
>
> At this point confusion fills my head and nonsense follows my commands
> on the command line.
>
> What does that all mean?
>
> Thank you very much for any help and de-confusion in advance! :)
>
> Best regards,
> mcc
HTH (and that I'm not totally off track)
- Matt