Find

From 6bit.ch wiki
Revision as of 16:07, 30 December 2022 by Xbl (talk | contribs) (Created page with "= find = Search for files in a directory hierarchy. The command is recursive by default.</br> == Use == <code>find /var/www -name '*.css'</code> prints full path/filename to all files in /var/www that end in .css <code>-name</code> filename matches string(case sensitive)</br> <code>-iname</code> filename matches string(case insensitive)</br> <code>-regex</code> filename matches regex(case sensitive)</br> <code>-iregex</code> filename matches regex(case insensitive)</b...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

find

Search for files in a directory hierarchy. The command is recursive by default.

Use

find /var/www -name '*.css' prints full path/filename to all files in /var/www that end in .css

-name filename matches string(case sensitive)
-iname filename matches string(case insensitive)
-regex filename matches regex(case sensitive)
-iregex filename matches regex(case insensitive)

-type x define result type
-type b block device
-type c character device
-type d directory
-type f file
-type l symlink
-type p named pipe
-type s socket

-size x define file size
-size -1M smaller than 1MB
-size +2G bigger than 2GB
-size +1M -size -10M bigger than 1M and smaller than 10M

-mtime x define modification time
-mtime -5 modified five or less days ago
-mtime +5 modified five or more days ago
-mtime +5 -mtime -10 modified more than five and less than 10 days ago

-perm x define permissions
-perm 754 match rwx rx r exactly
-perm /4 match defined permission for either user, group or others

Useful Flags

-L follow symbolic links
-not match inverse
-print0 do not treat whitespace as the end of a filename
-user x only match files belonging to specified user

-exec execute a command on matched files
{} placeholder to represent matched file
\; indicate the end of a parameter list