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?
ls *.mp3
could result in a very long list (out of memory / command line too long), depending on how many files that match the globbing pattern.bash
actually calls "ls aGoodSong1.mp3 boringSong2.mp3 coolSong.mp3
" (if you have those 3 files). A workaround:ls | grep -i '[.]mp3$'
(where ls lists all files and grep shows only the .mp3 files)echo *.mp3