[root@master ~]# .sh #!/bin/bash exec >> /tmp/.log >>/tmp/.log date ldkkdfkslfds date [root@master ~]# ./.sh [root@master ~]# .log Sat Jun :: UTC ./.: ldkkdfkslfds: command not found Sat Jun :: UTC Sat Jun :: UTC ./.: ldkkdfkslfds: command not…
centos shell脚本编程2 if 判断 case判断 shell脚本中的循环 for while shell中的函数 break continue test 命令 第三十六节课 return用在函数中exit用在shell当中 直接退出整个脚本,整个子shell或当前shellbreak退出循环 上半节课 if 判断case判断shell脚本中的循环 下半节课 for whileshell中的函数breakcontinue 课程大纲(继续上节课的) 7. if…
条件判断是一个程序获得智能的基础,而Bourne Shell脚本则通过命令 [ 来模拟大多数编程语言中的条件表达式. shell中支持的控制结构有: (1) if then else fi (2) for in do done (3) while do done 这些关键字可以引导程序检查状态码 $?,从而实现控制.下面讲解这个命令如何模拟条件表达式. 文件/目录判断[ -b FILE ] 如果 FILE 存在且是一个块特殊文件则为真.[ -c FILE ] 如果 FILE 存在且是一个字特殊文…