在Ubuntu下,通常用命令行打開文本文件,比如用命令gedit、more、cat、vim、less。但當需要打開其他格式文件時,比如pdf、jpg、mp3格式文件,咱們通常做法是進入到文件所在的目錄,雙擊打開,很影響效率。事實上,可以通過命令xdg-open(opens a file or URL in the user's preferred application)打開這些格式文件,甚至是網(wǎng)頁,像打開文件一樣簡單。
附xdg-open manual部分信息: xdg-open opens a file or URL in the user's preferred application. If a URL is provided the URL will be opened in the user's preferred web browser. If a file is provided the file will be opened in the preferred application for files of that type. xdg-open supports file, ftp, http and https URLs. xdg-open is for use inside a desktop session only. It is not recommended to use xdg-open as root.