Captain Claptrap
Captain Claptrap

Reputation: 3949

Ignore case when trying to match file names using find command in Linux

Right now, all I know to use is:

find / -name string.*

that is case sensitive and it won't find files named:

1string.x
STRing.x
string1.x

How can I search so that all the above would be returned in the search to a case-insensitive matching?

Upvotes: 15

Views: 16984

Answers (5)

Inian
Inian

Reputation: 85570

If the system you are in does not have the find command provided by the GNU utils package, you can use the -name tag alone with POSIX bracket expressions as

find . -name '*[Ss][Tt][Rr]ing*'

Upvotes: 1

JustinShoffstall
JustinShoffstall

Reputation: 161

This works as well, if you want to avoid the single quotes:

find . -iname \*string\*

Upvotes: 6

DigitalRoss
DigitalRoss

Reputation: 146043

Or you could use find / | grep -i string

Upvotes: 7

Anya Shenanigans
Anya Shenanigans

Reputation: 94614

Use -iname in find for case insensitive file name matches.

Upvotes: 2

llasram
llasram

Reputation: 4475

Use the -iname option instead of -name.

Upvotes: 27

Related Questions