OK - this is the first one that surprised me in this series - #1 and #2 were things I kind of knew had to exist, it was just a matter of finding them, but this one was more "Oh. Oh that's neat." Also, obvious in hindsight :D
We're talking about grep -Z.
Following on from #3, in fact - the -Z option spits out filenames from grep terminated by NUL. Same reasoning as find -print0, but allows you to do things like this:
grep -l -r -Z "error" . | xargs -0 cp -t failurelogs/
And yes, cp -t does exactly what you expect :D
Top comments (0)