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/user/Downloads/hello.c /Users/user/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/user/Downloads/hello.c /Users/user/Downloads/Y/Hello.C /Users/user/Downloads/Z/HELLO.c /Users/user/hello.c
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
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/user/Downloads/Z/HELLO.C /Users/user/Downloads/Z/HEllO.c /Users/user/Downloads/hello.c /Users/user/hello.c
No comments:
Post a Comment