Script to find executable based on extension of a file?

view full story

http://askubuntu.com – I need to create a script that returns the default app to be used for a given file extension (including the path). I had a look at the file command which can return the mime type and xdg-open which would open a file. But what I'd like to get is myscript doc /usr/bin/libreoffice .or. myscript fun /opt/acme/roadrunner/meepmeep How do I do that? (HowTos)