Reputation: 2049
I am looking for a way to list the contents of a directory on a UNIX system, that does not appear in a predefined "exclude" list.
Say i have a dir:
dir1
dir1-1
test1
test2
test3
dir1-2
test4
test5
and an "exclude list" as such:
dir1/dir1-1/test1
dir1/dir1-2/test5
I am interested in outputting
dir1/dir1-1/test2
dir1/dir1-1/test3
dir1/dir1-2/test4
And the actual command will be with both an exclude list and a directory structure with thousands of files, so performance is a bit of an issue.
Any ideas?
Upvotes: 1
Views: 442
Reputation: 290025
You can exclude them with the !
operator:
find . -type f ! \( -path "./dir1-1/test1" -o -path "./dir1-2/test5" \)
Note we are hardcoding the excludee path from the .
. So in case you execute it from another place you will need to add the corresponding path. Or, better, use full paths like:
find /your/path/ -type f ! \( -path "/your/path/dir1-1/test1" -o -path "/your/path/dir1-2/test5" \)
Upvotes: 2