Professional Documents
Culture Documents
the root directory $find. name searchFileName This is used to find the file name searchFileName from the current directory (where this command should executed) $ find . -type f -size 0 ls This is used to find files with zero size from current directory. $ find . -name "*.htm*" -type f This is used to find files end with .htm from current directory. $ find . -name "*" -type f -size +1000 This is used to find all files with size is greater than 1000k from current directory. $ find . -name foo.bar -type f 2> /dev/null This is used to find foo.bar file suppose it doesnot have any access permission it eliminate error message( 2>/dev/null). $ find . -type s This is used to find all socket files from current directory. $ find . -type d This is used to find all directory only. $ find . -type f This is used to find all normal files from current directory. $ find . -newer SK This is used to find all files after creating file name SK from current directory. $ find . -newer SK perm 777 This is used to find all files after creating file name SK from current directory that files must have all permission for all.
Find out all files owned by user applas $ find . -user applas name *.sh This is used to find all .sh files which are created by applas.
-atime +7: All files that were last accessed more than 7 days ago -atime 7: All files that were last accessed exactly 7 days ago -atime -7: All files that were last accessed less than7 days ago
-mtime +7: All files that were last modified more than 7 days ago -mtime 7: All files that were last modified exactly 7 days ago -mtime -7: All files that were last modified less than7 days ago
3. Quote: Originally Posted by ranj@chn Did you want to list the file that had the word 'get'. Is that the string you are referring to? Se if this works for you Code:
find /dir/from/where/you/want/to/search -type f -exec grep -l 'get' {} \; 2>/dev/null
Thanks dude, its been ages that i've searched for that kind of command! Knowing not the minus l option of grep, I used to Code:
find /dir/from/where/you/want/to/search -type f -exec cmd.sh 'get' {} \;
To find the files that contain a string we can use: find . -exec grep -l string to find {} \; This starts the search from the current directory, looks for files that contain the specified string, and then it prints their names.