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?

[donotprint][/donotprint]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


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:


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:


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:

See also

Posted by: SXI ADMIN

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.


Start your Bitcoin Exchange with our Software

Start your Bitcoin Exchange with our Software Setup your white label bitcoin exchange right away. Or create your own cryptocurrency using...

How to KVM, QEMU start or stop virtual machine from command line (CLI)

KVM or Kernel Based Virtual Machine is a popular virtualization technology. It allows you to run virtual guest machines over a host machine. To start...

How to Docker backup Saving and restoring your volumes

Running a Docker volume backup First, we spin up a temporary container, and we mount the backup folder and the target Docker volume to this container....