- Starting at location X
- Recursively find all entries that match
- Do something for each match
~ $ find //myserver/myshare/logs/000[4-9] -name \*.dat -newer logchecker.csv \
-exec /home/myuser/Sandbox/FileCheckers/logchecker \{\} \;
- Starting at
//myserver/myshare/logs/000[4-9]
- Find all files that end in
.dat
- That are also newer than
logchecker.csv
- Execute
logchecker
, passing in path to file
~ $ find //myserver/myshare/logs/000[4-9] -name \*.dat -newer logchecker.csv \
-exec /home/myuser/Sandbox/FileCheckers/logchecker \{\} \;
Backslashes prevent "shell expansion"
-executable
- the file is executable or the directory is searchable-group <gname>
- file belongs to group gname-iname <pattern>
- case-insensitive name search-name <pattern>
- case-sensitive name search-newer <file>
- newer than file-size <n>
- file uses n units of space- various measures like 512-byte blocks (
b
) through gigabytes (G
).
- various measures like 512-byte blocks (
-type <c>
- file is of type c- two most common -
d
(directory) orf
(file).
- two most common -
-user <uname>
- file is owned by uname.
-delete
- deletes any files matched so far- Actions are also tests (predicates)
- Don't put this first!
-exec
and-execdir
- executes a command or script-print
- prints the full path of the found file or directory-printf
- prints a formatted string, useful for reports
~ $ find . -type f -printf "%p\n%u\n%TY-%Tm-%TdT%TT\n\n"
./a
myuser
2015-10-21T11:02:51.7014527000