echo换行输出需要转义符 -e 看以下例子: echo -e "It is the first line." >> a; echo -e "It is the second line.\c" >> a; echo -e "It is the third line." >> a; echo -e "\nIt is the forth line." >> a 输出: It is t…
循环 shell中for循环的表现形式: 1.数字段形式 for i in {1..10};do echo $i;done 还支持按规定的步数进行跳跃的方式实现列表for循环,例如计算1-100内所有的奇数之和. sum=$((sum+i)) ....} do let "sum+=i" done echo "sum=$sum" 2.详细列出(字符且项数不多)for f in file1 file2 file3 file4 file5;do echo $f;done…
首先来一个小程序,来查看所在目录,以及该目录下的文件 #!/bin/sh # “#!”指定用sh执行shell脚本 #this is to show workstation # “#” 表示注释 echo "We are currently in the following directory" # echo 表示输出 /bin/pwd #输出用户所在目录 echo # 换行 echo "This directory contains the following files&…
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…