逻辑判断的格式 vim case.sh #!/bin/bash read -p "please input a number:" n m=$[$n%] case $m in ) echo " It is a jishu'" ;; ) echo " It is a oushu." ;; *) echo " Not is a jishu and oushu." esac 输入一串字符 赋值$n $m=$n除以2 判断$m 等于1…
创建一个shell脚本 mkdir shell vim first.sh #!/bin/bash ##The first test shell script. ##Written by wangshaojun. ls /tmp/ echo "my home is $HOME" echo "This is first script" 执行shell脚本,两种方法 bash first.sh mysql.sock www_slow.log2015-12-31.wangs…
while 死循环 vim while.sh #!/bin/bash ## while : do date +%T sleep done : 永久帧 查看时间 3秒循环1次 打印1-10 #!/bin/bash ## n=1 ] do echo $n n=$[$n+] done 交互循环 #!/bin/bash ## n= while [ ! -z "$n" ] do read -p "Please input a number:" m n=`echo $m |se…