I've tried using
find . | grep -v '(.ext1|.ext2)$'
But it still returns those files ending with extensions .ext1
and .ext2
. Then I tried the following:
ls | grep -v ".ext1$" | grep -v ".ext2$"
and this works how I want it. Is there another way to do what I'm looking for ? All I want to do is list all files or directories that do NOT end in .ext1
or .ext2
.
You have not escaped the .
try this . It will work. Remember .
needs to be escaped.
ls | grep -v '\.ext1$' | grep -v '\.ext2$'
same for your find
find . | grep -v '(\.ext1|\.ext2)$'
Hope that helps :)