如何在Windows 7命令提示符下运行.sh ?当我试着在里面运行这一行的时候总是会得到这个错误,

app/build/build.sh

错误,

'app' is not recognized...

or,

bash app/build/build.sh

错误,

'bash' is not recognized...

知道我错过了什么吗?

这里是截屏,


当前回答

Windows中的新功能-在Windows的ubuntu上运行bash -在Build会议后的Windows 10“Insiders”版本中可用:

https://blogs.windows.com/buildingapps/2016/03/30/run-bash-on-ubuntu-on-windows/

其他回答

您是否尝试过通过对.sh所在的根目录进行压缩以从那里执行它,而不是像您在问题中所示的那样写下文件的路径?

像这样:

$ cd app/build
$ build.sh

你也可以使用cder

Cmder是一个纯粹出于对Windows上缺少良好的控制台模拟器的不满而创建的软件包。它是基于惊人的软件,并与Monokai配色方案和自定义提示布局,从一开始看起来性感

cmder.net

我个人使用这个批处理文件,但它确实需要安装CygWin(如所示)。 只需将. sh文件类型与这个批处理文件(在我的例子中是ExecSH.BAT)关联起来,然后双击. sh,它就会运行。

@echo off
setlocal

if not exist "%~dpn1.sh" echo Script "%~dpn1.sh" not found & goto :eof

set _CYGBIN=C:\cygwin64\bin
if not exist "%_CYGBIN%" echo Couldn't find Cygwin at "%_CYGBIN%" & goto :eof

:: Resolve ___.sh to /cygdrive based *nix path and store in %_CYGSCRIPT%
for /f "delims=" %%A in ('%_CYGBIN%\cygpath.exe "%~dpn1.sh"') do set _CYGSCRIPT=%%A
for /f "delims=" %%A in ('%_CYGBIN%\cygpath.exe "%CD%"') do set _CYGPATH=%%A

:: Throw away temporary env vars and invoke script, passing any args that were passed to us
endlocal & %_CYGBIN%\mintty.exe -e /bin/bash -l -c 'cd %_CYGPATH%;  %_CYGSCRIPT% %*'

基于这个原创作品。

Windows中的新功能-在Windows的ubuntu上运行bash -在Build会议后的Windows 10“Insiders”版本中可用:

https://blogs.windows.com/buildingapps/2016/03/30/run-bash-on-ubuntu-on-windows/

在Windows 10周年更新中,在ubuntu上运行shell命令甚至更容易

我试图为我的x-wrt r7000 netgear路由器设置我的区域,我发现以下对我有用,在windows上使用ubuntu上的bash,你必须启用在windows功能中找到的子系统,并开启开发模式

ssh admin@192.168.1.1 < /mnt/c/ccode-eu.sh