2

Is there any command line command or any program which tells you or suggests you which programs you have installed on your system in order to run your passed file.

For example when I write command file, which command is that command which you suggest to me and file is my file. For example my file is a music file and the result will suggest you have VLC to run your file.

Or imagine you type command hello.txt and the result are geany and vi .

1 Answer 1

3

Three such programs that identify the file type and run or give a list of suggestions:

  • mimeopen
  • xdg-open
  • see

All of these can be run on the command line. Their behavior can be modified by various options. For example:

mimeopen -a filename

With the -a option, mimeopen will show a text menu of available programs and prompt you to choose one. Running mimeopen -a on a mp3 file, for example, might produce:

$ mimeopen -a somemusic.mp3 
Please choose an application

        1) VLC media player  (vlc)
        2) Enqueue in SMPlayer  (smplayer_enqueue)
        3) GNOME MPlayer  (gnome-mplayer)
        4) SMPlayer  (smplayer)
        5) Audacious  (audacious)

use application #

The last line above is a prompt. If you enter 1,2,3,4 or 5, the associated program will start. Enter anything else and mimeopen will terminate.

In contrast:

mimeopen -n filename

The above will not ask. It will just run the default program on filename. To choose/set the default for a file, run:

mimeopen -d filename
1
  • 1
    OP need to know which programs can open a file in terminal , not to open them
    – nux
    May 25, 2014 at 18:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .