This is a read-only archive. Find the latest Linux articles, documentation, and answers at the new Linux.com!

Linux.com

How about xargs?

Posted by: Anonymous Coward on July 11, 2006 12:57 AM
I don't think any discussion of GNU find is complete without including xargs. Example:

find ~/Music -type f -iname "*.mp3" -print0 | xargs -0 mp3gain -r -k

would be able to troll your ~/Music folder for files named '*.mp3' or '*.MP3' (case insensitive is -iname) and run mp3gain on all those.

This approach is vastly superior to the -exec option in most cases because it only fires off one mp3gain process, which makes it much faster.

Maybe someone can refute my next claim; I found that adding -type f was almost a necessity, and that the operation was actually faster. Not a lot faster, but fast enough to justify typing it in. Anyone care to weigh in on that one?

#

Return to CLI Magic: Searching with find