Big_t boy
Big_t boy

Reputation: 329

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!

Upvotes: 1

Views: 117

Answers (3)

crazier wu
crazier wu

Reputation: 21

find in current file not recursive

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

Upvotes: 2

glenn jackman
glenn jackman

Reputation: 246807

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

shopt -s extglob
ls !(*.txt)

reference

Upvotes: 2

tweej
tweej

Reputation: 842

find ! -name  "*.txt"

or

find -not -name "*.txt"

Upvotes: 0

Related Questions