Linux等效的Mac OS X“打开”命令 [英] Linux equivalent of the Mac OS X "open" command
问题描述
我发现Mac OS X中的open命令在命令行中非常方便。从man open:
I've found the "open" command in Mac OS X very handy in the command line. From "man open":
open
命令打开一个文件目录或URL),就像你有
双击文件的图标一样。如果未指定应用程序名称,则通过LaunchServices确定的
默认应用程序用于打开
指定的文件。
The
open
command opens a file (or a directory or URL), just as if you had double-clicked the file's icon. If no application name is specified, the default application as determined via LaunchServices is used to open the specified files.
也就是说,如果我想使用默认的PDF查看器(恰好是Preview)打开一个PDF文件,我只需要:
That is, if I want to open a PDF file with the default PDF viewer (happens to be Preview), I only need to do:
open my.pdf
然而,在Linux中,打开PDF文件命令行,我不得不去找找默认的PDF查看器是,例如,evince(谁已经猜到了),然后
In Linux, however, to open a PDF file from the command line, I had to dig around to find the default PDF viewer is, for instance, "evince" (who'd have guessed??), and then
evince my.pdf
推荐答案
在Linux命令行中使用'open'命令
您可以尝试 xdg-open
,大多数Linux发行版都有它。它会为您的文件打开默认关联的应用。
You could try xdg-open
, most Linux distros have it. It will open default associated app for your file.
FYI https://portland.freedesktop.org/doc/xdg-open.html
这篇关于Linux等效的Mac OS X“打开”命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!