macos 如何使用终端执行 .command 文件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7369134/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to execute a .command file using Terminal?
提问by Hyman Humphries
Once I navigate to a certain directory that has a .command file in it, how do I execute that file using Terminal?
一旦我导航到某个包含 .command 文件的目录,我该如何使用终端执行该文件?
回答by Lily Ballard
If you want to execute it as if it was double-clicked in the Finder, you can use open foo.command
. This will spawn a new Terminal window. If you want to execute it "inline", as it were, you can just use ./foo.command
, as .command files must have the exec bit set in order to function.
如果您想像在 Finder 中双击一样执行它,您可以使用open foo.command
. 这将产生一个新的终端窗口。如果你想“内联”执行它,你可以只使用./foo.command
,因为 .command 文件必须设置 exec 位才能运行。