Linux commands to find files based on type, size etc.

Use below command for finding some files and searching text into those files,
repalce 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.

Android Android Commands Android Java Applications Application Libraries Application Stack / User Interface Bash / Shell Scripts Commands and Packages Compilation Content Management System - CMS Core Kernel C Programs Development & Build Development Environment Setup Errors & Failures Flutter git Go Language Programs Hardware Platforms HTML JAVA Programs Kernel & Device Drivers Linux, OS Concepts and Networking Linux Device Drivers Linux Host, Ubuntu, SysAdmin Linux Kernel Linux Networking Middleware Libraries, HAL Monetization / Google AdSense Multimedia - Audio, Video, Images NDK / Middleware / HAL OS Concepts PHP Programming Languages RaspberryPi Scripting and Automation Search Engine Optimisation ( SEO ) Social Media Socurce Code Management ( SCM ) System Administration, Security Testing and Debugging Uncategorized User Interface Web design and development Wordpress Yocto / Bitbake / Openembedded

Leave a Reply / Ask Question