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

90 Views Asked by At

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!

3

There are 3 best solutions below

0
On BEST ANSWER

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

shopt -s extglob
ls !(*.txt)

reference

0
On
find ! -name  "*.txt"

or

find -not -name "*.txt"
1
On

find in current file not recursive

find -maxdepth 1 ! -name "*.txt"