Some time ago I’ve posted about using multiple -exec options for find command which can be used to find in what JARs particular class lies. Below you can find enriched and more intuitive/detailed solution for finding your class in a bunch of JARs:
Tag Archives: find
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.
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 ! \( -iname "*.class" -o -iname "*.jar" \)
The above command uses the OR operation to find all files in the current directory (and subdirectories) which have extension different than “class” or “jar”. Don’t forget about the parentheses escaping!
Didn’t need this feature before today, but I guess it might be quite handy.