find
- Files named filename.suffix
find . -type f -exec grep -ls nohup.out {} \;
- Greater than or equal to 100KB
find . -size +100k -exec ls -l {} \; | \
awk '{printf $9, $5}'
- Greater than or equal to 100KB. Sort the output numerically
find . -size +100k -exec ls -l {} \; | \
awk '{printf "%40s %10s \n", $9, $5}' | \
sort -n +1
- Changed in the last 7 hours
find / -ctime -7 -print
- Modified in the last 7 hours
find / -daystart -mtime -7 -print
- Files of type Directory
find . -type d -print
- Owned by user username
find / -user jdoe -print 2>/dev/null
- Owned by userid number
find / -uid 227 -print 2>/dev/null
- Prompt user before removing a file
find / -name nohup.out -ok rm {} \;
- Case insensitive search
find . -iname
- Find files under current directory named string.scr or string.prt
find . \( -name "*.scr" -o -name "*.rpt" \) -print
- Find core files. Prompt user for deletion
find / -name core -ok rm {} \;
- Files that end with 'log'
find / -print 2>/dev/null | \
grep log\$
- Files that start with 'law'
find / -print 2>/dev/null | \
grep \^law
- Files changed within the last hour
find . -ctime -1 -exec ls -l {} \; 2>/dev/null
- Files not changed within the last year. Prompt user for deletion
find . -ctime +$(print $((365*20))) -exec ls -l {} \; -ok rm {} \;
- Symbolic links
find . -type -l -print
find . -type -l -exec ls -l {} \;
- Files older than 30 days
cd /var/backup/logs find . -daystart -mtime +30 -print
- Files older than 30 days. Remove.
find . -daystart -mtime +30 -print -exec rm {} \;
- Files older than 30 days. Prompt for removal.
find . -daystart -mtime +30 -print -ok rm {} \;
- Edit all files that contain string
vi `find . -name string -print 2>/dev/null`
- Changed in the last 20 hours, greater than 1MB in size, excluding some file systems
find . -ctime -20 -size +1000k -print | grep -v \/usr | grep -v \/var | grep -v \/ora