bash 如何通过 Cygwin 在 Windows 7 上运行 .sh 文件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22722604/
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 run .sh file on Windows 7 through Cygwin?
提问by sozhen
I have to use a package on my Windows 7OS but the package comes only with the .sh
file so I have to use bash and hence Cygwin to run on my machine.
我必须在我的Windows 7操作系统上使用一个包,但该包只随.sh
文件一起提供,所以我必须使用 bash 并因此使用 Cygwin 在我的机器上运行。
But I am kinda familiar with Windows but completely new to Cygwin and shell programming.
但我对 Windows 有点熟悉,但对 Cygwin 和 shell 编程完全陌生。
Suppose I have a run.sh
file in /cygdrive/c/Users/myUserName/Desktop/software/myPackage/bin
, how should I run it in Cygwin?
假设我有一个run.sh
文件/cygdrive/c/Users/myUserName/Desktop/software/myPackage/bin
,我应该如何在 Cygwin 中运行它?
Downloaded Cygwin and in the terminal I navigate to that directory and type run.sh
enter but it complains
下载 Cygwin 并在终端中导航到该目录并输入run.sh
enter 但它抱怨
$ run.sh
-bash: run.sh: command not found
I am asking this because I generally understand in Windows you can just navigate to the directory and run the .bat
file and that's it?
我问这个是因为我通常理解在 Windows 中您只需导航到目录并运行.bat
文件就可以了?
How does this work for Cygwin? Any suggestion are highly appreciated!
这对 Cygwin 有何作用?任何建议都非常感谢!
回答by anubhava
You can run it as:
您可以将其运行为:
bash run.sh
Or else:
要不然:
chmod +x run.sh
./run.sh