DEV Community

Cover image for Don’t Click, Just grep: The Smart Way to Find Files Fast
Victor Maina
Victor Maina

Posted on

Don’t Click, Just grep: The Smart Way to Find Files Fast

How to Use grep to Find Files by Extension Like a Command-Line Ninja
Ever found yourself swimming in a sea of downloads trying to fish out all the .jpg images? If you love clean terminals and fast results, grep has your back.

Here’s how to use grep like a pro to filter files by extension straight from your terminal.

📁 List .jpg Files in Downloads
bash

ls ~/Downloads | grep '\.jpg$'

📁 Case-Insensitive Search (JPG, jpg, JpG...)
bash

ls ~/Downloads | grep -i '\.jpg$'

🔁 Search Recursively Through Subfolders
bash

find ~/Downloads -type f | grep '\.jpg$'

💡 Bonus: Windows Equivalent
CMD:
cmd

dir %USERPROFILE%\Downloads\*.jpg

PowerShell:
powershell

Get-ChildItem "$env:USERPROFILE\Downloads" -Filter *.jpg

Top comments (0)

Some comments may only be visible to logged-in visitors. Sign in to view all comments.