Showing posts with label Find files using file name in Linux. Show all posts
Showing posts with label Find files using file name in Linux. Show all posts

Sunday 20 December 2015

Find files using file name in Linux

create two file named saidrasel.c into current directory /root/test and /root/test/backup directory

[root@stelar_test test]# touch saidrasel.c
[root@stelar_test test]# cd backup/
[root@stelar_test backup]# touch saidrasel.c


Now execute the find command to search saidrasel.c file from /root/test location
[root@stelar_test test]#pwd
/root/test
[root@stelar_test test]# find -name saidrasel.c
./backup/saidrasel.c
./saidrasel.c
[root@stelar_test test]#

Now execute the find command to search saidrasel.c file from / location

[root@stelar_test /]# find -name saidrasel.c
./root/test/backup/saidrasel.c
./root/test/saidrasel.c
[root@stelar_test /]#

Now execute the find command to search saidrasel.c file from any location

[root@stelar_test oracle]# pwd
/home/oracle

Following search will start from / (root) location

[root@stelar_test oracle]# find / -name  saidrasel.c
/root/test/backup/saidrasel.c
/root/test/saidrasel.c
[root@stelar_test oracle]#

[root@stelar_test oracle]# find / -name  saidrasel*
/root/test/backup/saidrasel.c
/root/test/saidrasel.c

[root@stelar_test oracle]# find / -name  saidrase*
/root/test/backup/saidrasel.c
/root/test/saidrasel.c

[root@stelar_test oracle]# find / -name  saidra*
/root/test/backup/saidrasel.c
/root/test/saidrasel.c
[root@stelar_test oracle]#

Find Files Using Name and Ignoring Case


[root@stelar_test oracle]# find / -iname  "SaidRasel.c"
/home/oracle/SaidRasel.c
/root/test/SaidRasel.c
/root/test/backup/saidrasel.c
/root/test/saidrasel.c
[root@stelar_test oracle]#

[root@stelar_test oracle]# find / -iname  "saidrasel.c"
/home/oracle/SaidRasel.c
/root/test/SaidRasel.c
/root/test/backup/saidrasel.c
/root/test/saidrasel.c
[root@stelar_test oracle]#