Search a file with specific name
It will search for sample.txt for GFG directory
$ find. /GFG -name sample.txt
Search a file with pattern
It will give all which have .txt at the end
$ find ./GFG -name*.txt
when this command is entered a prompt will come for cnfirmation, ti delete sample.txt or not. ir you enter y/y it will delete the file
$ ./GFG -name sample.txt -exec rm -i {} \;
search for empty files and directories
$ find./GFG -empty
search the file with entred permission
$ find ./GFG -perm 664
search text within multiple lines
$ find ./-type f -name "*.txt" -exec grep 'geek' {}\;
find files using name and ignoring cases
$ find /home -iname tecmint.txt
find all read only files
$ find / -perm/u=r
find executable files
$ find /-perm/ a=x
find size between from xMB - y MB
$ find / -size + xM-size -yM
find size between from xMB - y MB
$ find / -size + xM-size -yM
find and remove single file
$ find .type f -name "techmint.txt" -execrm -f {}\;
find all empty directories
$ find /tmp -type d -empty
find all hidden files
$ find / tmp -type f -name ".*"
find all files which are modified more than 50 days and less than 100 days
find / -mtime +50 -mtime -100
to find all files which are changd in the last 1 hour
$ find /-cmin -60
to find all files which are changd in the last 1 hour
$ find /-cmin -60
search for sample.txt in GFG directory
$ find ./GFG -name sample.txt
it will give all file which have .txt at the end
$find ./gfg -name *txt
it is used to delete the file
$find ./GFG -name sample.txt -exec rm-i {}\;
tfind all empty files in the directory
$find ./GFG empty
find all files in the given directory with the given permissions
$ find ./GFG -perm 664
print line which have geek in them and type f specifies the input type is a file
$ find ./ -type f -name "*.txt"-exec grep 'geek' { }\;
searches directories with a specific name
$ -type d -name puttygen
find files within this modified range
find /-mtime +30 -mtime -90
files modified with less than a specific time
find / -cmin -30
check newly created files
find /-newer test.txt
find the files more than the given size
find / tmp -size 40k
search the folder for a partcular name and shows the results and one needs to ececute the command
find /tmp -iname *trial* -exec is -1d {};
Searches for example.txt inside /home/user (case-sensitive).
find /home/user -name "example.txt"
Finds example.txt, Example.txt, EXAMPLE.TXT, etc.
find /home/user -iname "example.txt"
Searches for all text files (.txt) in /home/user/Documents.
find /home/user/Documents -type f -name "*.txt"
Finds directories named projects.
find /home/user -type d -name "projects"
Searches for files larger than 100MB in the entire system.
find / -type f -size +100M
Finds files in /var/log modified within the last 7 days.
find /var/log -type f -mtime -7
Finds and deletes all .log files inside /home/user/logs.
find /home/user/logs -type f -name "*.log" -delete
Finds all .sh files and lists them with detailed info using ls -lh.
find /home/user -type f -name "*.sh" -exec ls -lh {} \;
Finds empty files and empty directories in /home/user.
find /home/user -type f -empty
find /home/user -type d -empty
Finds files modified in the last 30 days and archives them into recent_files.tar.gz.
find /home/user/Documents -type f -mtime -30 -print | tar -czvf recent_files.tar.gz -T -
to search the file in directory with name
find . -name "07_05*"
Searches for files in a directory hierarchy based on conditions.
find /home -name "*.txt"