Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I ask this question for running an find command.

I want to list all mp3(lets say) using the find command.How to do this without having an extension.

share|improve this question
up vote 6 down vote accepted

This will do it for almost all audio files. Strangely it missed some here because they were of type "application/octet-stream". Maybe they are badly encoded.

find -type f -exec file --mime-type '{}' \+ | grep "audio/mpeg"

or without mimetype in the list

find -type f -exec file --mime-type '{}' \+ | grep "audio/mpeg" | sed 's;:\s*audio/mpeg$;;'

share|improve this answer
I suggest + in lieu of \; and \s* in lieu of the space between : and audio. – enzotib Jul 6 '11 at 14:24
Great. But I was looking for a more general solution, which would work for other types, like pictures or videos.Can it be extened? – Mad-scientist Jul 6 '11 at 14:46
This command can give a hint of the mime type to use for a given extension, say mp3: awk '/mp3/ { print $1 }' /etc/mime.types – enzotib Jul 6 '11 at 15:11
Mad-scientist: every file has a type. file <file> is the best way to determine a file's type. Returning a MIME type is only one possibility. Read man file for further information. – dAnjou Jul 6 '11 at 21:57

Your Answer


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.