Linux 相当于 Mac OS X“开放"命令 [英] Linux equivalent of the Mac OS X "open" command

查看:21
本文介绍了Linux 相当于 Mac OS X“开放"命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现 Mac OS X 中的打开"命令在命令行中非常方便.来自人开":

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"命令等价物?

So, is there a simple equivalent of the 'open' command in the Linux command line?

谢谢!

推荐答案

你可以试试 xdg-open,大多数 Linux 发行版都有.它将为您的文件打开默认关联的应用程序.

You could try xdg-open, most Linux distros have it. It will open default associated app for your file.

仅供参考 https://portland.freedesktop.org/doc/xdg-open.html

这篇关于Linux 相当于 Mac OS X“开放"命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆