name - linux find files not in directory




Exclude list of files from find (3)

I don't think find has an option like this, you could build a command using printf and your exclude list:

find /dir -name "*.gz" $(printf "! -name %s " $(cat skip_files))

Which is the same as doing:

find /dir -name "*.gz" ! -name first_skip ! -name second_skip .... etc

Alternatively you can pipe from find into grep:

find /dir -name "*.gz" | grep -vFf skip_files

If I have a list of filenames in a text file that I want to exclude when I run find, how can I do that? For example, I want to do something like:

find /dir -name "*.gz" -exclude_from skip_files

and get all the .gz files in /dir except for the files listed in skip_files. But find has no -exclude_from flag. How can I skip all the files in skip_files?


I think you can try like

find /dir \( -name "*.gz" ! -name skip_file1 ! -name skip_file2 ...so on \)

find /var/www/test/ -type f \( -iname "*.*" ! -iname  "*.php" ! -iname "*.jpg" ! -iname "*.png"  \)

The above command gives list of all files excluding files with .php, .jpg ang .png extension. This command works for me in putty.





find