The following config will few examples on how to quickly search a filesystem for files based on file extension. For this we only need two command line tools find and grep. First, lets search for all files with a filename extension .sh recursively within /home/ directory:
$ find ~/ -type f | grep "\.sh$"
Using the find command we have searched for all files within ~/ user home directory and used grep to print only those files ending with .sh filename extension. In the following example we will search for all files with filename extension .sh, .txt and .py:
$ find  ~/ -type f | grep -E "\.sh$|\.txt$|\.py$"
Using the above example we can also perform an action on each file. For example the following linux command will remove all files from user home directory ~/ with filename extension .sh, .txt and .py:
$  find  ~/ -type f | grep -E "\.sh$|\.txt$|\.py$" | xargs -I {} rm {}
FIND LATEST LINUX JOBS on LinuxCareers.com
Submit your RESUME, create a JOB ALERT or subscribe to RSS feed.
LINUX CAREER NEWSLETTER
Subscribe to NEWSLETTER and receive latest news, jobs, career advice and tutorials.
DO YOU NEED ADDITIONAL HELP?
Get extra help by visiting our LINUX FORUM or simply use comments below.

You may also be interested in: