Wayne Werner
Wayne Werner

Reputation: 51877

Linux list files recursively ignoring a pattern

I have exactly the same problem as this post.

Only instead of finding all the .txt files, I want a list of all files that are not .txt files.

Something like

$ ls -LR | grep -v .java

Which definitely does not do what I want.

Upvotes: 0

Views: 433

Answers (2)

fedorqui
fedorqui

Reputation: 290155

Use find as suggested in that post and negate the -name condition with ! to have the other way round:

find . -type f ! -name "*.txt"
#      ^^^^^^^ ^^^^^^^^^^^^^^^
#   just files        |
#              file names not ending with .txt

Upvotes: 1

Nachiket Kate
Nachiket Kate

Reputation: 8571

Does this work for you?,

ls -lr | grep -E -v "*.txt$"  

I tested it on my end and it worked, -E extended grep

Upvotes: 0

Related Questions