1 |
On 07/18/11 23:12, meino.cramer@×××.de wrote: |
2 |
> Hi, |
3 |
> |
4 |
> the manual page of grep mentioned the following: |
5 |
> |
6 |
> -Z, --null |
7 |
> 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 |
8 |
> after each file name instead of the usual newline. This option makes the output unambiguous, even in the presence of file names containing unusual |
9 |
> 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, |
10 |
> even those that contain newline characters. |
11 |
> |
12 |
> for me (as a non-native English speak ;) ) this means: |
13 |
> |
14 |
> Replace a newlie after a filename with a zero-byte. |
15 |
> |
16 |
> So when doing |
17 |
> |
18 |
> find /tmp | grep -Z tmp | xargs -0 md5sum |
19 |
> |
20 |
> it should work comparable to |
21 |
> |
22 |
> find /tmp -print0 | xargs -0 md5sum |
23 |
> |
24 |
> but for me it does not. |
25 |
> |
26 |
> If my logic is not complete nonsense I dont understand the second |
27 |
> part of the text of the manual page: |
28 |
> |
29 |
> |
30 |
> This option can be used with commands like find -print0, perl -0, sort -z, and xargs -0 to process arbitrary file names, |
31 |
> even those that contain newline characters. |
32 |
> |
33 |
> |
34 |
> If I would do |
35 |
> |
36 |
> |
37 |
> find /tmp -print0 | grep -Z tmp | xargs -0 md5sum |
38 |
> |
39 |
> 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 |
40 |
> after each file name instead of the usual newline. ".... |
41 |
|
42 |
|
43 |
This took me a few minutes to actually figure out exactly what -Z in |
44 |
supposed to do. But I *think* it does exactly this. Whatever character |
45 |
comes directly after the filename is replaces by NUL. As you can see in |
46 |
my example below, the character that normally follows a filename is ':' |
47 |
(a colon), but with the -Z option, the colon is replace with NUL, this |
48 |
no 'character' follows it. |
49 |
|
50 |
~/joe/sullivan $ grep -Z document ./* |
51 |
./core.js$(document).ready(function() { |
52 |
./core.js $(document).pngFix(); |
53 |
./core.js var map = new |
54 |
google.maps.Map(document.getElementById("map_of_region"), myOptions); |
55 |
|
56 |
~/joe/sullivan $ grep document ./* |
57 |
./core.js:$(document).ready(function() { |
58 |
./core.js: $(document).pngFix(); |
59 |
./core.js: var map = new |
60 |
google.maps.Map(document.getElementById("map_of_region"), myOptions); |
61 |
|
62 |
|
63 |
But please do correct me if I'm wrong. |
64 |
|
65 |
> |
66 |
> At this point confusion fills my head and nonsense follows my commands |
67 |
> on the command line. |
68 |
> |
69 |
> What does that all mean? |
70 |
> |
71 |
> Thank you very much for any help and de-confusion in advance! :) |
72 |
> |
73 |
> Best regards, |
74 |
> mcc |
75 |
|
76 |
HTH (and that I'm not totally off track) |
77 |
|
78 |
- Matt |