15

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?

1

5 Answers 5

27

Use the -iname option instead of -name.

Sign up to request clarification or add additional context in comments.

4 Comments

what about the characters before and after the string? will -iname return names with extra characters?
@micah: If you tell it to. find . -iname '*string*'
Ok, but -iname is not a Posix find option. Posix does specify shell pattern matching for -name.
@DigitalRoss The original poster specified the 'linux' tag, so I think assuming the GNU findutils is reasonable.
7

Or you could use find / | grep -i string

2 Comments

find does this natively. Creating another process just to do that is going to make it slower.
True but it's easy to remember and consistent with the software tools pattern. Find does do shell globbing on plain old -name, it is true.
6

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

find . -iname \*string\*

1 Comment

find . -iname *YOUR_PATTERN* -type f
2

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

Comments

1

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*'

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.