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?

link|improve this question

71% accept rate
feedback

1 Answer

up vote 8 down vote accepted

Have you tried ls *.mp3?

link|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 – o_O Tync 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
feedback

Your Answer

 
or
required, but never shown

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