Gentoo Archives: gentoo-user

From: meino.cramer@×××.de
To: Gentoo <gentoo-user@l.g.o>
Subject: [gentoo-user] [OT]: grep -Z not working ???
Date: Tue, 19 Jul 2011 03:14:07
Message-Id: 20110719031253.GA3448@solfire
1 Hi,
2
3 the manual page of grep mentioned the following:
4
5 -Z, --null
6 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
7 after each file name instead of the usual newline. This option makes the output unambiguous, even in the presence of file names containing unusual
8 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,
9 even those that contain newline characters.
10
11 for me (as a non-native English speak ;) ) this means:
12
13 Replace a newlie after a filename with a zero-byte.
14
15 So when doing
16
17 find /tmp | grep -Z tmp | xargs -0 md5sum
18
19 it should work comparable to
20
21 find /tmp -print0 | xargs -0 md5sum
22
23 but for me it does not.
24
25 If my logic is not complete nonsense I dont understand the second
26 part of the text of the manual page:
27
28
29 This option can be used with commands like find -print0, perl -0, sort -z, and xargs -0 to process arbitrary file names,
30 even those that contain newline characters.
31
32
33 If I would do
34
35
36 find /tmp -print0 | grep -Z tmp | xargs -0 md5sum
37
38 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
39 after each file name instead of the usual newline. "....
40
41 At this point confusion fills my head and nonsense follows my commands
42 on the command line.
43
44 What does that all mean?
45
46 Thank you very much for any help and de-confusion in advance! :)
47
48 Best regards,
49 mcc

Replies

Subject Author
Re: [gentoo-user] [OT]: grep -Z not working ??? Matthew Finkel <matthew.finkel@×××××.com>
Re: [gentoo-user] [OT]: grep -Z not working ??? Neil Bothwick <neil@××××××××××.uk>