You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Find all files and sub-directories in the current directory
find .
Find all files in the current directory
find . -type f
Find all sub-directories in the current directory
find . -type d
Find all files starting with the word "test" (case sensitive)
find . -type f -name "test*"
Find all files starting with the words "test" or "Test" (case insensitive)
find . -type f -iname "test*"
Search using metadata
Files modified less than 5 minutes ago
find . -type f -mmin -5
Files modified more than 5 minutes ago
find . -type f -mmin +5
Files modified more than 1 minute and less than 5 minutes ago
find . -type f -mmin +1 -mmin -5
Files modified less than 10 days ago
find . -type f -mtime -10
Files modified more than 10 days ago
find . -type f -mtime +10
Note: Like mmin and mmtime, one may also use amin and atime to find files / directories
accessedx minutes and days ago respectively. Similarly, cmin and ctime will look for files / directories
changed (owner, permissions etc...) x minutes and days ago respectively.
Files with size greater than 1MB
find . -type f -size +1M
Files with size less than 1MB
find . -type f -size -1M
Files with size greater than 1kB
find . -type f -size +1k
Files with size greater than 1GB
find . -type f -size +1G
Find empty files and directories
find . -empty
Find files / directories by permission
find . -perm 777
Excluding sub-directories using maxdepth
Find html files in current directory (exclude sub-directories)
find . -maxdepth 1 -type f -name "*.html"
Find html files in current directory and only those sub-directories that are exactly one level below
find . -maxdepth 2 -type f -name "*.html"
Execute commands against results of find using exec
Change the owner and group of all files
find . -type f -exec chown owner_name:group_name {} +
Remove html files in only the current directory (exclude sub-directories)