The*_*sai 26
你应该把脚本作为你运行的*NIX shell的参数,相当于*NIXish
sh myscriptfile
Run Code Online (Sandbox Code Playgroud)
Mar*_*edi 23
Windows 10上现在有一个"本机"解决方案,在Windows上启用Bash后,您可以通过输入bash以下命令输入Bash shell :

您可以运行Bash脚本bash ./script.sh,但请记住C驱动器位于/mnt/c,并且外部硬盘驱动器不可安装.因此,您可能需要稍微更改脚本,以便与Windows兼容.
此外,即使如此root,您仍然可以在移动文件时获得权限被拒绝/mnt,但您root在/文件系统中拥有全部功能.
还要确保您的shell脚本使用Unix样式格式化,否则可能会出错.

如果将扩展添加.SH到环境变量PATHEXT,则只能使用带参数的脚本名称,从PowerShell运行shell脚本:
PS> .\script.sh args
Run Code Online (Sandbox Code Playgroud)
如果将脚本存储在PATH环境变量中包含的目录中,则可以从任何位置运行它,并省略扩展名和路径:
PS> script args
Run Code Online (Sandbox Code Playgroud)
注意:sh.exe或其他*nix shell必须与.sh扩展名关联.
小智 9
也可以通过导出Windows Server 环境变量的 Advance 部分中的bash and shgitbash来运行C:\Program Files\git\bin\。
在路径VAR部前进亲切添加C:\Program Files\git\bin\这将使bash与sh该混帐的bash的是从可执行文件window cmd。
然后,
运行 shell 文件作为
bash shellscript.sh 或者 sh shellscript.sh
| 归档时间: |
|
| 查看次数: |
99453 次 |
| 最近记录: |