os:find
Return to Home page
If you found any error, or if you want to partecipate to the editing of this wiki, please contact: admin [at] skenz.it
You can reuse, distribute or modify the content of this page, but you must cite in any document (or webpage) this url: https://www.skenz.it/os/find
The find command
Return to Operating Systems Course
Examples about the find
Linux command
- Find all the files, starting from the current working directory and using the
-name
option with nameaBcBa.txt
find . -name "aBcBa.txt"
- Find, using the
-regex
option, if the current working directory contains a file with nameaBcBa.txt
find . -regex "\./aBcBa.txt"
- Find all the files, starting from the current working directory and using the
-regex
option with nameaBcBa.txt
find . -regex ".*/aBcBa.txt"
- Find all the regular files in the current working directory whose name starts with an
A
or with ana
, followed by one character, followed by andA
or ana
, followed by a sequence of characters, and terminated with the extension.txt
find . -type f -iname "a?a*.txt" find . -type f -regex ".*/[aA].[aA][^/]*\.txt"
- Find all the regular files starting from the parent of the current working directory, whose name contains two lower case
a
separate bya
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"
- Find all the regular files starting from the home directory which have not the
777
permissions:
find ~ -type f ! -perm 777
- Find all the directories starting from the root of the file system which have the
777
permissions, and change their permission in755
:
find / -type d -perm 777 -exec chmod 755 \{} \;
- Find all the regular files starting from the current working directory whose name has extension .txt, and remove then
find . -type f -name "*.txt" -exec rm -f \{} \;
- Find all the regular files starting from the
/tmp
directory that are empty
find /tmp -type f -empty
- Find all the elements starting from the current working directory, whose name is
x.txt
ory.txt
find . -regextype posix-extended -regex ".*/(x|y).txt"
- Find all the elements starting from the directory
/home
owned by the userstefano
whose name has extension.txt
find /home -user stefano -iname "*.txt"
- Find all the elements starting from the directory
/home
owned by the groupdeveloper
find /home -group developer
- Find all the elements starting from the root of the file system with size greater than 50 Megabytes and lower than 100 Megabytes
find / -size +50M -size -100M
- Find all the regular files starting from the root of the file system whose name has extension
.mp3
and their size is greater than 10 Megabytes, and remove them
find / -type f -name "*.mp3" -size +10M -exec rm \{} \;
- Find all the regular files starting from the current working directory, whose name has extension
.c
or.sh
find . -type f \( -name "*.c" -o -name "*.sh" \)
- Find all the regular files starting from the current working directory, whose name finishes with the string
cache
orxml
orhtml
find . -type f \( -name "*cache" -o -name "*xml" -o -name "*html" \)
- Find all the elements in the home directory with the modification date more recent than 1440 minutes (one day)
find ~ -mmin -1440
- Find all the elements in the home directory with the modification date more recent than one day (as previous command)
find ~ -mtime -1
- Find all the elements in the home directory with the modification date between 10 and 14 days
find ~ -type f -mtime +10 -mtime -14
If you found any error, or if you want to partecipate to the editing of this wiki, please contact: admin [at] skenz.it
You can reuse, distribute or modify the content of this page, but you must cite in any document (or webpage) this url: https://www.skenz.it/os/find
/web/htdocs/www.skenz.it/home/data/pages/os/find.txt · Last modified: 2024/04/08 22:35 by 127.0.0.1