Put -print and -print0 last in a unix command find expression

published Sep 22, 2010 06:28   by admin ( last modified Sep 22, 2010 06:28 )

 

I had treated "-print0" as just another flag to the find command. It is not: In fact when find encounters a "-print" or "-print0" command it prints right then and there, and any flags coming thereafter are ignored (unless another -print or print0 command follows them).

I first tested like this:

find -print0 -name "*.mp3" |xargs -0 tag-command --flags

But that is wrong! The -name flag is completely ignored

This is the way it should be:

find -name "*.mp3" -print0|xargs -0 tag-command --flags

Thanks to jax for pointing this out.

This actually works:

find -print0 -name "*.mp3" -print0|xargs -0 tag-command --flags

If you for some crazy reason would like to pass all files to the tag-command, but pass mp3 files twice...