foxfirefey: A guy looking ridiculous by doing a fashionable posing with a mouse, slinging the cord over his shoulders. (geek)
foxfirefey ([personal profile] foxfirefey) wrote in [community profile] command_liners2009-10-06 02:10 pm

Find and xargs are some of my favoritest things

There is something imminently satisfying about using find and xargs to accomplish tasks on files in the folder tree:

find . -name "*.orig" | xargs rm

I use it to delete certain leftover files from editors or version control systems, or to change the permissions on all of a certain kind of file. I also use it to recursively grep in certain instances:

find . -name "*.pl" | xargs grep -i "OpenID"

Here are a couple of articles for those interested in learning more about this awesome combo:

Advanced techniques for using the find command
Unix Xargs Piping Toolkit Utility
sophie: A cartoon-like representation of a girl standing on a hill, with brown hair, blue eyes, a flowery top, and blue skirt. ☀ (Default)

[personal profile] sophie 2010-08-03 09:32 pm (UTC)(link)
This is a late reply, but it turns out that on GNU grep, at least, you can use the -H switch to grep as an alternative to using the /dev/null trick.