Return to Operating Systems Course
Examples about the find Linux command
-name option with name aBcBa.txtfind . -name "aBcBa.txt"
-regex option, if the current working directory contains a file with name aBcBa.txtfind . -regex "\./aBcBa\.txt"
-regex option with name aBcBa.txtfind . -regex ".*/aBcBa.txt"
A or with an a, followed by one character, followed by and A or an a, followed by a sequence of characters, and terminated with the extension .txtfind . -type f -iname "a?a*.txt" find . -type f -regex ".*/[aA].[aA][^/]*\.txt"
a separate by a character, eventually proceeded and followed by a sequence of characters and with extension .txt (e.g., aaa.txt, axa.txt, 123axa.txt, axa123.txt, 123axa456.txt)find . -type f -regex ".*a.a[^/]*\.txt"
777 permissions:find ~ -type f ! -perm 777
777 permissions, and change their permission in 755:find / -type d -perm 777 -exec chmod 755 \{} \;
find . -type f -name "*.txt" -exec rm -f \{} \;
/tmp directory that are emptyfind /tmp -type f -empty
x.txt or y.txtfind . -regextype posix-extended -regex ".*/(x|y).txt"
/home owned by the user stefano whose name has extension .txtfind /home -user stefano -iname "*.txt"
/home owned by the group developerfind /home -group developer
find / -size +50M -size -100M
.mp3 and their size is greater than 10 Megabytes, and remove themfind / -type f -name "*.mp3" -size +10M -exec rm \{} \;
.c or .shfind . -type f \( -name "*.c" -o -name "*.sh" \)
cache or xml or htmlfind . -type f \( -name "*cache" -o -name "*xml" -o -name "*html" \)
find ~ -mmin -1440
find ~ -mtime -1
find ~ -type f -mtime +10 -mtime -14