windows 如何在cygwin中执行shell脚本?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5335262/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 08:11:23  来源:igfitidea点击:

How to execute shell script in cygwin?

windowsshellcygwin

提问by lily

the name.sh already save in C:\Documents and Settings\user, i type sh name.sh

name.sh 已经保存在 C:\Documents and Settings\user 中,我输入 sh name.sh

sh: testing.sh: No such file or directory

sh: testing.sh: 没有那个文件或目录

any help will be appreciated!

任何帮助将不胜感激!

回答by Chris Cooper

You can just type ./name.shand your script should run.

您只需键入即可./name.sh运行您的脚本。

If your current directory is not in your $PATH, adding the ./tells the shell to look there.

如果您的当前目录不在您的 中$PATH,则添加./告诉外壳程序查看那里。

The other possibility is that you're not currently in the right directory. If the result of pwdshows you are not in C:\Documents and Settings\user, then you will need to cdto that directory, or move the script to whatever directory you are in.

另一种可能性是您当前不在正确的目录中。如果结果pwd显示您不在C:\Documents and Settings\user,那么您需要cd到该目录,或将脚本移动到您所在的任何目录。

回答by detroitpro

Add ./ in front of the name. ./name.sh

在名称前添加 ./。./name.sh