reason

Well, I can't remember everything...

Friday 9 August 2013

Searching for a file using Unix command line

This will search the current directory and all sub-directories for an exact match of string in quotes

find . -name "searchstring" -print
 
Here is an example with output

[root@cacti /]# find . -name "cacti" -print
./etc/logrotate.d/cacti
./var/backups/cacti
./var/lib/mysql/cacti


You can add asterisks as a wild card. The example below finds any filename that contains the search string

[root@cacti /]# find . -name "*cacti*" -print
./etc/logrotate.d/cacti
./home/cacti-0.8.8a
./usr/libexec/webmin/cactiez
./var/backups/cacti
./var/lib/mysql/cacti

No comments:

Post a Comment