More than one -exec in find

I was trying to execute several commands on a single record found by the GNU/Linux find command. The first attempt was to create something like: find . -name "*.pdf" -exec echo 'test' && echo 'test2' \; But it’s not the way the find command works. If you want to execute more than one command for each hit, you should use multiple -exec actions: find . -name "*.pdf" -exec echo 'test' \; -exec echo 'test2' \; I used this feature to list JAR files in a specified location along with classes they consist of:...

April 24, 2011 · 1 min

BASH -- find files with names different than the pattern

If you’re using BASH find and want to find files which are named differently than the given pattern, you can use the following syntax: find . -type f ! -iname "*.class" The above command will find all files in the current directory (and subdirectories) which have the extension different (exclamation mark) from “class” (case insensitive). You can also use conditional operations to build slightly more complicated commands, like: find . -type f !...

March 27, 2011 · 1 min