假设我在某个地方有一个名为file.ext的唯一文件。它是由我的Ubuntu box索引的,所以命令locate file.ext正确地给了我(单个)位置,比如/usr/local/some/place/file.ext。
所以我想这是:
locate file.ext | xdg-open我会用与文件类型相关联的默认应用程序打开文件(有一个,这不是问题),就像我输入了xdg-open /usr/local/some/place/file.ext一样
相反,我得到了来自xdg-open的"usage“消息,就好像它是在没有参数的情况下被调用的。
所以问题是:我是不是搞错了管道?或者这是那个特定命令的问题?
发布于 2013-06-15 21:44:41
因为您必须将filename作为选项传递,而不是在stdin上传递data。为此,请使用xargs:
locate file.ext | xargs xdg-open或者仅仅是subshell:
xdg-open "$( locate file.ext )"https://stackoverflow.com/questions/17124288
复制相似问题