示例脚本及注释 #!/bin/bash -x for filename in t1 t2 t3 do touch $filename.txt echo "Create new file: $filename.txt" done for rmfile in *.txt; do rm $rmfile; echo "Delete $rmfile!"; done; # set -x for filelist in `ls /root` do echo "filen…
示例脚本及注释 #!/bin/bash function Check() # 使用function定义函数 { Say # 通过函数名直接调用函数 if test $1 then return 0 # 使用return语句返回值: else echo "Command not implemented for that parameter!" exit 2 # 退出当前shell,并设置退出码为2: fi } Say() # 直接定义函数 { echo "This is a t…
示例脚本及注释 #!/bin/bash var=$1 # 将脚本的第一个参数赋值给变量var if test $var # test - check file types and compare values then if [ $var == "right" ];then # "[]"是调用test命令的一种形式,"[]"两边必须加空格; echo "Right!" elif test $var = "wrong&…