Anyway to obtain list of Application that can open a file via Terminal?
Open will consult the same database as finder to match a file type to potential apps. The name for this database is the Launch Serices Database and it's quite large and unwieldy if you dump it all.

 lsregister -dump | wc -l


I have 533,000 lines of text in my database, so you might need to narrow down what you're seeking rather than just consuming the entire fire hose of data about every possible file type and every possible application. If you don't have lsregister in your path, find it here and optionally make a sym link to it in /usr/local/bin

mdfind -name lsregister
ln -s $(mdfind -name lsregister) /usr/local/bin


But, if you want the whole enchilada - you can dump the database and dig into the glorious technical details.

Let's go two more steps down the rabbit path. Say you have a movie file on your desktop. You would use the metadata listing tool to dump all the attributes of that file (61 entries for one movie I have) and then you have to parse out the content type to match that up with the database dump from launch services.

mdls ~/Desktop/video.mov | wc -l


And to pick out just the one most specific content type (since a file has a tree of potential content types - you may have to consider them as well in your search - but since we're keeping this simple - let's assume the final type is what's matched for your case)

mdls ~/Desktop/video.mov | grep -w kMDItemContentType


So for me, that movie is categorized by spotlight indexing as a com.apple.quicktime-movie type file and in the launch services dump - one of the apps that claims to open that file is /Applications/QuickTime Player.app

Scripting this is going to be quite an exercise, but the data is there for you to examine and play with. Enjoy!

This other question has some awesome more detail and a tool called http://duti.org that might be the tool you seek. Even better, it's open source so you can see how it works.


Programmatically/Script-atically changing the default Open-With setting