Tell me more ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

On Windows I used to quickly run a dir *.mp3 to find all files with an mp3 extension in the current directory. Is there a similarly quick way to do it with bash? The ls command seems to have a way to ignore a pattern, but not to show only the pattern. I can do find . -maxdepth 1 -iname '*.mp3' or ls|grep -i '\.mp3$' but neither of these flow out of my fingers in half a second or less)

Any quicker alternatives?

share|improve this question

1 Answer

up vote 8 down vote accepted

Have you tried ls *.mp3?

share|improve this answer
2  
Ooh, er, that's a bit strange. It works! I'm sure that was the first thing I tried way back when. Is there any situation where this doesn't work? Thanks for responding:) – Andy Jun 17 '10 at 11:16
Yep, it won't show '*.MP3' files. You'll need to use grep -i in order to ignore the case – kolypto Jun 17 '10 at 11:28
1  
Or just do ls *.mp3 *.MP3 – Paul R Jun 17 '10 at 11:47
... but: ls *.[mM][pP]3 will. – JRobert Jun 17 '10 at 11:48
I've been meaning to post about this for some time. Maybe it was a problem with dir /s *.mp3... anyways, thanks for an answer! – Andy Jun 17 '10 at 12:14

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.