windows下如何运行shell脚本

windows下如何运行shell脚本

1、安装 git

官网:https://git-scm.com/

下载安装即可

2、打开git bash

3、进入工作目录

75377@DESKTOP-1N42TVH MINGW64 ~
$ pwd      ## 查看当前目录
/c/Users/75377

75377@DESKTOP-1N42TVH MINGW64 ~
$ cd C:/Users/75377/Desktop/test      ## 切换目录,注意是反斜杠

75377@DESKTOP-1N42TVH MINGW64 ~/Desktop/test
$ pwd
/c/Users/75377/Desktop/test

75377@DESKTOP-1N42TVH MINGW64 ~/Desktop/test

4、测试

75377@DESKTOP-1N42TVH MINGW64 ~/Desktop/test
$ ls
test.sh*

75377@DESKTOP-1N42TVH MINGW64 ~/Desktop/test
$ cat test.sh       ## 测试脚本, 直接用vim创建即可
#!/bin/bash
echo "hello world!"

75377@DESKTOP-1N42TVH MINGW64 ~/Desktop/test
$ bash test.sh        ## 直接bash运行, 输出运行结果
hello world!

75377@DESKTOP-1N42TVH MINGW64 ~/Desktop/test
原文地址:https://www.cnblogs.com/liujiaxin2018/p/15678393.html