Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have the following command which lists all files that have the extension .swf however I would like to return a list of every file that does not have the extension .swf

find . -maxdepth 1 -regextype posix-egrep -regex '.*/.*\.swf' -exec echo {} \;
share|improve this question

2 Answers 2

up vote 3 down vote accepted

Just negate the condition

-not -regex '.*/.*\.swf'
share|improve this answer
    
That works like a charm. Is there however a way just using regular expressions? –  PeanutsMonkey Mar 30 '13 at 21:40
    
Hmmm ... a -regex '.*/.*\.[^s][^w][^f]' kind of works, I guess. –  tink Mar 31 '13 at 5:28

If all you want are the files that don't have the .swf extension, just use reverse grep :

find . -maxdepth 1 -type f | grep -v *\.swf

Or, negate the -name with find:

find . -maxdepth 1 ! -name "*\.swf"
share|improve this answer

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.