≡ Menu

Linux/Unix: Find Command Ignore Case Insensitive Search

I am a new Linux and Unix-command line user. I am using find command to search file called “fooBar.conf.sample” in my home directory. I do not know the case, it could be uppercase, lowercase, or a mix of both. How can search a file and ignore case on a Linux or Unix-like system?

The find command recursively descends the directory tree for each path provided, evaluating an expression. It is mainly used to search files and directories on Linux and Unix-like systems. The syntax is as follows to search files according to given criteria. You can search for files by name, owner, group, type, permissions, date, and other criteria:

find dir-to-look criteria what-to-do

OR

find [options] dir-to-look criteria what-to-do

In this example, search your $HOME for a file called hello.c:

find $HOME -name "hello.c" -print

This will search the whole $HOME (i.e. /home/username/) system for any files named “hello.c” and display their pathnames:

/Users/vivek/Downloads/hello.c
/Users/vivek/hello.c

However, it will not match HELLO.C or HellO.C. To match is case insensitive pass the -iname option as follows:

find $HOME -iname "hello.c" -print

Sample outputs:

/Users/vivek/Downloads/hello.c
/Users/vivek/Downloads/Y/Hello.C
/Users/vivek/Downloads/Z/HELLO.c
/Users/vivek/hello.c

Finally, pass the -type f option to only search for files:

find /dir/to/search -type f -iname "fooBar.conf.sample" -print
find $HOME -type f -iname "fooBar.conf.sample" -print

A note about AIX/HP-UX and other old Unix-like systems

The -iname works either on GNU or BSD (including OS X) version find command. If your version of find command does not supports -iname, try the following syntax using grep command:

find $HOME | grep -i "hello.c"
find $HOME -name "*" -print | grep -i "hello.c"

OR try

find $HOME -name '[hH][eE][lL][lL][oO].[cC]' -print

Sample outputs:

/Users/vivek/Downloads/Z/HELLO.C
/Users/vivek/Downloads/Z/HEllO.c
/Users/vivek/Downloads/hello.c
/Users/vivek/hello.c
See also
Share this tutorial on:

Your support makes a big difference:
I have a small favor to ask. More people are reading the nixCraft. Many of you block advertising which is your right, and advertising revenues are not sufficient to cover my operating costs. So you can see why I need to ask for your help. The nixCraft, takes a lot of my time and hard work to produce. If you use nixCraft, who likes it, helps me with donations:
Become a Supporter →    Make a contribution via Paypal/Bitcoin →   

Don't Miss Any Linux and Unix Tips

Get nixCraft in your inbox. It's free:



{ 2 comments… add one }
  • Anthony June 20, 2014, 1:28 am

    the locate command fines file on a system. adding -i has it ignore case

    locate -i hello.c

    However it will also find directories with the same name that can produce a long for something like “hello” to prevent this use something like this

    locate -ir /hello.c$

    That will locate a the exact but case insensitive filename “hello.c”

  • Kholofelo Maloma April 18, 2016, 7:51 am

    Thanks. Very useful. I also found that with the locate command, you can add a parameter -i to ignore case

Leave a Comment

You can use these HTML tags and attributes: <strong> <em> <pre> <code> <a href="" title="">


   Tagged with: