0% found this document useful (0 votes)
57 views1 page

Find Command

This document provides examples of find commands to search for files and directories based on different criteria such as name, size, modified time, empty/hidden files, and condition. Some examples include: 1) Finding .txt files in the current or specified directory. 2) Searching for files less than or greater than a certain size. 3) Finding files accessed or modified within a certain time period. 4) Locating empty files and directories as well as hidden files in the /tmp directory. 5) Searching for a file by name and deleting it.

Uploaded by

Midun Siva
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views1 page

Find Command

This document provides examples of find commands to search for files and directories based on different criteria such as name, size, modified time, empty/hidden files, and condition. Some examples include: 1) Finding .txt files in the current or specified directory. 2) Searching for files less than or greater than a certain size. 3) Finding files accessed or modified within a certain time period. 4) Locating empty files and directories as well as hidden files in the /tmp directory. 5) Searching for a file by name and deleting it.

Uploaded by

Midun Siva
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

#TO MOVE A FILE INTO ANOTHER DIRECTORY

cp -r copy1.txt details # to move a file into a directory

1)to find a file or directory using name

find . -name \*.txt # . stands for the current directory

find details -name \*.txt # to search .txt files only in details directory (can add
multiple dir)

find . -iname "copy1.txt" # to search a file ignoring the case of the filename

find / -type d -name details # to search a directory type file

find . -type f -name "*.txt" # to search in pwd all files of type .txt

2) TO SEARCH A FILE BASED ON ITS SIZE

find . -size -10M # to search in pwd all files of size less than 10MB

find . -size +1c -size -5M # to find files in pwd that are greater than 1 byte and
less than 5 MB

3) TO FIND A FILE BASED ON THE MODIFIED TIME

find . -atime -1 # to find files that were accessed in the last one day

find . -mtime -60 #finding files in pwd that were modified in the last hour

find . -atime -60 #finding files in pwd that were changed in the last hour

find . -ctime -60 #finding files in pwd that were accessed in the last hour

4) TO FIND EMPTY FILES, HIDDEN FILES AND DIRECTORIES IN /tmp DIRECTORY

find /tmp -type f -empty # to find in /tmp all empty files

find /tmp -type d -empty # to find in /tmp all empty directories

find /tmp -type f -name ".*" # to find in /tmp all hidden files

5)TO FIND A FILE BASED ON SOME CONDITION AND TO DELETE IT

find . -type f -name "COPY1.txt" -exec rm -f {} \; # to find a file and execute a


command on it.

You might also like