Home » Linux Host, Ubuntu, SysAdmin » Linux Commands » How to use Find command to search files based on File Size, File Type ?

How to use Find command to search files based on File Size, File Type ?

Use below command for finding some files and searching text into those files, replace DIR_TO_SEARCH with the proper path of directory you want to search in,

Linux command for find and grep

 $ find DIR_TO_SEARCH -name '*.c' -exec grep -i 'main' {} \; -print 

This command, finds all c files in DIR_TO_SEARCH directory and greps text “main” into those c files and prints the path of file on console.

Linux command to find file more that certain specified size

 $ find DIR_TO_SEARCH -size +100M 

This command, finds all files in DIR_TO_SEARCH directory which are more than 100MB and prints the path of file on console.

Linux command to find and remove certain files

 $ find DIR_TO_SEARCH -type f -name FILE_TO_DELETE -exec rm -f {} \; 

Linux command to find a file with name

 $ find DIR_TO_SEARCH -name hellowordld.pdf 

This command will find a pdf file with name ellowordld.pdf you need to use your filename.


Subscribe our Rurban Life YouTube Channel.. "Rural Life, Urban LifeStyle"

Leave a Comment