1:实现shell脚本中循环调用函数
1 #!/bin/bash 2 3 output(){ 4 for(( num1=1; num1 <= 5; num1++ )) 5 do 6 echo -n "$num1 " 7 done 8 } 9 10 let "num2=1" 11 while [ "$num2" -le 5 ] 12 do 13 output 14 echo 15 let "num2=num2+1" 16 done
实现结果:
2:判断系统是否存在此文件
1 #!/bin/bash 2 #文件系统相关测试 3 4 fpath="/etcc/passwd" 5 if [ -e $fpath ];then 6 echo File exits; 7 else 8 echo Does not exits 9 fi