I have a lot of directories on my system, with a structure looking like this:
\-----data
\------- 001abc
\------- 002abc
\------- 003abc
\------- 004abc
\------- 005abc
\ ....
When I want find a certain directory, I just type find . -iname "002abc*"
but how can I find a directory excluding certain name matches?
Something like this in MySQL select * from folder where filename != '0021bc'
Best Answer
Use
!
in afind
command to negate (invert) the option following after. In your case:and optionally, only matching folders:
will list all folders except the ones named matching the pattern
002abc*
.The
!
can be problematic in shell scripting sometimes, so as Flimm pointed out, the-not
parameter is a very useful synonym to it.