示例脚本及注释 #!/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&…
1,带参数的shellscript #this is program build 5.11 to test shell script ############ cxz ####### 5.11 ############ echo "you have given $0 $# argument" echo "the argument you give is \n $@" #$0表示所执行的shellscript $#表示shellscript 所带的参数总数 [ $#…
脚本地址 https://github.com/anliven/L-Shell/tree/master/Shell-Basics 示例脚本及注释 #!/bin/bash var=$1 # 将脚本的第一个参数赋值给变量var if test $var # test - check file types and compare values then if [ $var == "right" ];then # "[]"是调用test命令的一种形式,"[]&qu…
示例脚本及注释 #!/bin/bash # for循环 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; # 写成一行的方式 for filelist in `ls /root` # 循环显示/root目录…