windows

  1. 删除文件夹 rd /S /Q <文件夹>

Shell

脚本暂停

read -p "Press any key to continue." var

Shell传递参数

  • 脚本内获取参数的格式为:$n。n 代表一个数字,1 为执行脚本的第一个参数,2 为执行脚本的第二个参数,以此类推,其中 $0 为执行的文件名
deploy.sh first
// deploy.sh
$1=first

if else

  • if else写法
#!/bin/sh
a=10
b=20
if [ $a == $b ]    # if与[ ]有空格,"["  、 "]"与字符都有空格
then echo "a is equal to b"
else echo "a is not equal to b"
fi
  • if … elif … fi 语句可以对多个条件进行判断
#!/bin/sh
a=10
b=20
if [ $a == $b ];then
    echo "a is equal to b"
elif [ $a -gt $b ];then
    echo "a is greater than b"
elif [ $a -lt $b ];then
    echo "a is less than b"
else
    echo "None of the condition met"
fi

查询占用指定端口进程的PID

打开cmd命令行,输入netstat -ano|findstr 8080(指定端口号)

最后一列即为占用该端口的进程的PID

KILL指定PID的进程

紧接着在命令行输入taskkill /pid 21172(PID参数) -f