find

BSD find Cheatsheet #

find is used to search for files in a directory hierarchy based on various criteria on BSD systems.

Basic Usage #

Command/OptionExampleDescription
find /path -name filenamefind /home/user -name document.txtFind files named document.txt in /home/user
find /path -type ffind /home/user -type fFind all regular files in /home/user
find /path -type dfind /home/user -type dFind all directories in /home/user
find /path -size +100Mfind /var -size +100MFind files larger than 100 MB

Advanced Usage #

Command/OptionExampleDescription
`find /path -name “*.txt” -print0xargs -0 ls -l``find /home/user -name “*.txt” -print0
find /path -mtime -7find /var/log -mtime -7Find files modified in the last 7 days
find /path -user usernamefind /home/user -user johnFind files owned by user john
find /path -perm 644find /home/user -perm 644Find files with permission mode 644

Deletion and Actions #

Command/OptionExampleDescription
find /path -name "*.tmp" -exec rm -f {} \;find /tmp -name "*.tmp" -exec rm -f {} \;Delete all .tmp files in /tmp
find /path -name "*.log" -exec rm -f {} \;find /var/log -name "*.log" -exec rm -f {} \;Delete all .log files in /var/log

This cheatsheet covers essential find commands and options for BSD systems.

find

Explore our comprehensive cheatsheets to enhance your knowledge and efficiency. Each cheatsheet provides detailed command options, examples, and descriptions to help you master various tools and technologies.