DEV Community

Mike Whitaker
Mike Whitaker

Posted on


Shell command options you didn't know you needed (or possibly even existed) #4

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)

Timeless DEV post...

Git Concepts I Wish I Knew Years Ago

The most used technology by developers is not Javascript.

It's not Python or HTML.

It hardly even gets mentioned in interviews or listed as a pre-requisite for jobs.

I'm talking about Git and version control of course.

One does not simply learn git