Difference between revisions of "Find"
Jump to navigation
Jump to search
(Created page with "Category:Shell Find things on a unix filesystem ;<code>find <directory> -type f -name '<spec>' </code> :find file in and below <directory> that match <spec>. Type f is fo...") |
m |
||
Line 1: | Line 1: | ||
− | [[Category: | + | [[Category:Linux/Unix]] |
− | Find things on a | + | Find things on a filesystem |
;<code>find <directory> -type f -name '<spec>' </code> | ;<code>find <directory> -type f -name '<spec>' </code> |
Revision as of 14:06, 31 May 2019
Find things on a filesystem
find <directory> -type f -name '<spec>'
- find file in and below <directory> that match <spec>. Type f is for files, d for directory's, no type finds all.
find <directory> -type f -name '<spec>' -exec <command> {} \;
- For each file found execute <command> {} represents the found file. NOTE!! Do not forget the \; at the end.
find <directory> -type f -name '<spec>' -mtime 1
- Find files modified 1 day ago (between 24 and 48 hours).
- Negative numbers find all files modified max 1 day ago.
- Positive numbers (explicitly signed with +) find all files at modified at least 1 day ago.
-mmin
counts minutes instead of days.
find <directory> -type f -name '<spec>' -printf '%T@ %p\n'
- Print the files modification times in epoch (seconds since Jan 1, 1970) and the filename. Can be used e.g. to find the last files modified (with sort -n and tail)