grep - How to search a directory/directories in unix by excluding certain file extensions -


i've tried using

find . | grep -v '(.ext1|.ext2)$' 

but still returns files ending extensions .ext1 , .ext2. tried following:

ls | grep -v ".ext1$" | grep -v ".ext2$"  

and works how want it. there way i'm looking ? want list files or directories not end in .ext1 or .ext2.

you have not escaped . try . work. remember . needs escaped.

 ls | grep -v '\.ext1$' | grep -v '\.ext2$'  

same find

find . | grep -v '(\.ext1|\.ext2)$'

hope helps :)


Comments

Popular posts from this blog

vb.net - Alternative to the T-SQL AS keyword -

php - MySQLi binding parameters in a prepared statement doesn't work unless inserted after "WHERE" -

ios - CFRelease causing crash in iPad application -