
find - search for files in a directory hierarchy.
find . -name file.txt
./file.txtfind command. means it will search all the directory you are in and sub directories.-name will look for that name exactly, if a character is different or upper or lower case, it will ignore it.file.txt filenamefind /home/ -iname file.txt
./file.txt
./File.txtfind / -type -d -name Photos file.txt
/home/user/Photosfind /home/ -name *ile*
./home/file.txt
./home/File.txt
./home/My_Files-NEWS.txt
./home/file.shfind / -type -f -name Photos *.odt
./file.odt
./terminalroot.odt-f only files with extension odt, in that case, even without -f would also find
777find . -type f -perm 0777 -print777find / -type f ! -perm 777- type d or - type f it searches bothfind MyDir/ -empty
MyDir/EmptyDir
MyDir/EmptyFile.txt-type d search only directoriesfind MyDir/ -type d -empty
MyDir/EmptyDir-type f looks for files onlyfind MyDir/ -type f -empty
MyDir/EmptyFile.txtfind /tmp -type f -name ".*"find . -type f -size +10MYou will find all files smaller than 10MB
find. -type f -size -10M
-execfind . -type f -name EmptyFile.txt -exec rm -f {} \;Or with xargs
find . -type f -name EmptyFile.txt | xargs rm -ffind My_Files/ -name "*.*" -exec grep -Hin "Anomalies" {} \;
My_Files/file.txt:1:Anomaliesatime) files in the last 24 hours (for more than 3 days, use +3)find . -type f -atime -1 -exec ls -l {} \;amin) files in last 5 minutesfind . -type f -amin -5ctime) files in the last 12 hoursfind . -type f -ctime -0.5 -exec ls -l {} \;
mtime) files in the last 6 hoursfind . -type f -mtime -0.25551 Permissionfind / -perm 1551find / -perm /u=sfind / -perm /g+sfind / -perm /a=xor read only
find / -perm /u=rThere are more possibilities, you can see them all in the command manual:
man find
find --helpThanks for reading!