Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm trying to copy all files of a type in a given directory and subdirectories but excluding files of a different type.

find /var/ftp/pub/bs -iname "*foo*.foo" -exec cp {} /var/ftp/pub/bs1 \;

which works but I'd rather do the exclude which is more accurate.

So I need to copy files with that end with *.foo but exclude files that contain foo1

Something like this (which doesn't work)

find /var/ftp/pub/bs -iname "*.foo" | grep --exclude="*foo1*" -exec cp {} /var/ftp/pub/bs1
share|improve this question

1 Answer 1

find ... -iname "*.foo" ! -iname "*foo1*" ...

You may need to escape the ! depending on your shell.

share|improve this answer
    
That worked. I did need to escape it. Thanks much! –  user11064 Sep 27 '11 at 5:00

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.