Search code examples
linuxls

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.


Solution

  • 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