Search code examples
linuxshellfind-util

search files in current directory whose name do not contain "txt" in linux


I know how to find files with suffix .txt in the current directory: find *.txt

How do I invert this?

I am new to Linux, so please help. Thanks!


Solution

  • If you just want the current directory, and your shell is bash:

    shopt -s extglob
    ls !(*.txt)
    

    reference