Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .