Linux/find

find
Find file syntax: find [path] [expression] find [path] -name [pattern] find [path] -iname [pattern] find. -iname "test"
 * 1) case sensitive
 * 1) case insensitive

man find: -mtime n             File’s data was last modified n*24 hours ago. See the comments for -atime to understand  how rounding affects the interpretation of file modification times.

Time modifier: +n    for greater than n, -n     for less than n, n      for exactly n.

Find all files modified within the last 'n' days: find [path] -mtime [+//-][n] find /etc -mtime -1
 * 1) to find all files modified today:

Find all files modified within the last 'n' minutes: find [path] -mmin [+//-][n] find /etc -mmin -60
 * 1) to find all files modified within the last hour:

Filter (exclude) certain folders: find. -type d -not -path "./badpath/*" -not "./badpath2/*" -print

Find files between two dates: find Your_Mail_Dir/ -newermt "2011-01-01" ! -newermt "2011-12-31"

find large files
find files larger than 100M:

find / -type f -size +100M -not -path "/proc/*" -not -path "/sys/*" -exec ls -lh {} \; | awk '{ print $9 ": " $5 }'
 * 1) RHEL

find / -type f -size +100M -not -path "/proc/*" -not -path "/sys/*" -exec ls -lh {} \; | awk '{ print $8 ": " $5 }'
 * 1) Ubuntu

find small files
Find files smaller than 500 bytes:

find ~ -size -500b

Find Executable Files
Files and folders (natural): find -executable

Files only: find -executable -type f

Delete files older than n days
Delete files older than 30 days: find /path/to/files/ -type f -name '*.jpg' -mtime +30 -exec rm {} \;

Files Owned by User
Find by user: find /var -user vivek

Find by group: find /home -group ftpusers