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

Post Free Ads for Agri, Solar, Eco products

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 Bash / Shell Scripts Bluetooth driver Build Frameworks Commands and Packages Core Kernel C Programs Development Environment Setup Documents / Books Errors & Failures File Systems Framebuffer / Display Driver git Go Language Programs Hardware Platforms Home JAVA Programs Kernel & Device Drivers Kernel Booting and Porting Linux, OS Concepts and Networking Linux Device Drivers Linux Host, Ubuntu, SysAdmin Linux Kernel Linux Networking Middleware Libraries, HAL NDK / Middleware / HAL Network Driver OS Concepts PHP Procfs Filesystem Programming Languages RaspberryPi Scripting and Automation Search Engine Optimisation ( SEO ) Socurce Code Management ( SCM ) System Administration, Security Testing and Debugging Uncategorized Userspace Utilities Web design and development Wordpress Yocto / Bitbake / Openembedded

Leave a Reply