The document provides examples of find commands to search for files and directories based on different criteria such as name, contents, size, permissions, owners and times. Some examples include using find to search the current directory for files containing "needle" in the name, find empty files in /tmp, find files modified over 90 minutes ago, and find PDFs owned by the user "seamstress".
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
28 views1 page
Command - Find
The document provides examples of find commands to search for files and directories based on different criteria such as name, contents, size, permissions, owners and times. Some examples include using find to search the current directory for files containing "needle" in the name, find empty files in /tmp, find files modified over 90 minutes ago, and find PDFs owned by the user "seamstress".
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1
find /dir -option param
find command in examples
Example: find . -iname “*needle*”
Where & What - Names, files & directories
look for “needle.txt” within the current directory & its subdirectories find . -name “needle.txt” ignore case, find “Needle” & “needle” find . -iname “needle” name contains “needle”; list only matching files find . -type f -name “*needle*” search everywhere; list only matching directories find / -type d -name “needle” additionally ignore all errors, such as “Permission denied” find / 2>/dev/null -type d -name “needle”
Check file contents
check all .txt files whether they contain “needle” find . -type f -iname "*.txt" -print | xargs grep “needle" same as above, but now it also works with filenames that contain spaces find . -type f -iname "*.txt" -print0 | xargs -0 grep "needle" find all empty files in /tmp find /tmp -type f -empty remove all these empty files find /tmp -type f -empty -print | xargs rm -f
File sizes & Times
files bigger than 50MB but smaller than 100MB find / -type f -size +50M -size -100M created during the last 50 days find / -ctime -50 modified more than 90 minutes ago Permissions & Owners find / -mmin +90 accessed during the last 24 hours but find all executable files not within the last hour find / -perm /a=x find / -atime -1 -amin +60 find files that don’t have 644 permissions find / -type f ! -perm 644 find files with 777 permissions a nd change them to 755 find / -type f -perm 0777 -print -exec chmod 755 {} \; find all PDFs owned by user “seamstress” (-group exists, too) find / -user seamstress -iname “*.pdf”
Content by Corinna Baldauf - finding-marbles.com
Designed by Wall-Skills.com - Knowledgable 1-Pagers