UNIX: how to find files that DO NOT match a pattern or other criteria
December 20th, 2008
Most people with some basic command line skills can readily issue the unix find command to find files of a specific type or matching a specific pattern.
You can do the exact opposite, that is, find files that do not fulfil a specific criterion. The "secret" is to precede an exclamation mark (!) in the argument list, just before the criterion that you want to negate.
For example:
The above command will find all files that have not an .mp3 extension.
You can do the exact opposite, that is, find files that do not fulfil a specific criterion. The "secret" is to precede an exclamation mark (!) in the argument list, just before the criterion that you want to negate.
For example:
# find . -type f ! -iname "*.mp3"The above command will find all files that have not an .mp3 extension.