Linux – Find files with find

, <span>Linux – Find files with find</span>, KandZ

find recurses the filesystem tree from any particular location and locate files that match the conditions we specified.

find /bin -name cp   # search for files or directories inside /bin that has the name cp

find /bin -iname CP  # the same as above and ignores the case of filenames

find /bin -type d -name cp   #  the -type d searches only for directories

find /bin -type f -name cp    # the -type f searches only for files


We can search files based on time and size.

find / -ctime 2  # find files that their status has been changed the last 2 hours

find / -atime 2  # find files that have been accessed the last 2 hours

find / -mtime 2  # find files that have been modified the last 2 hours

find / -size +10k  # find files that have size bigger than 1o kilobytes


b  for 512 bytes which is the default

c for bytes

w for two-byte words

k for kilobytes

M for megabytes

G for gigabytes

+ for greater than

–  for less than


An other good thing about find is that we are able to use commands on the files that matches our criteria. We can do that with -exec.

find -name "*.tmp" -exec rm {} ';'

The above command find all files that have tmp extension then delete them with the rm. The ‘{}’ will hold all the file names from the find command. We have to end the command with ‘;’ or \;



17900cookie-checkLinux – Find files with findLinux – Find files with find

Related posts

Leave a Comment