Skip to main content


Basic usage #

find [where] [options] [what]

find all mp3 files in /mnt/media:

find /mnt/media -name "*.mp3"

-type f = files, d = directories

mute errors for searching /:

find / -name "hosts" 2> /dev/null

Extra options #

find files modified within the last X days:

find /var/log -type f -mtime -1

find files modified more than X days ago:

find /var/log -type f -mtime +30

find files of a certain size (+/-):

find /mnt/media -type f -size +1G

find files by permissions:

find /home -type f -perm 0777

Executing commands on files #

find files and move them somewhere:

find . -type f -name "*.md" -exec cp {} ~/notes/ \;

{} = placeholder for what find is finding ; = ; ends the command, needs escape character

use xargs instead of exec:

find /etc -type f | xargs grep "" 2> /dev/null

xargs will batch the input before executing, -exec will run the command once for each input item