shell
lijie19870626
这个作者很懒,什么都没留下…
展开
-
linux中awk的使用
awk -F ‘:’ ‘{print $1}’ test.txt 将test.txt中第1段打印出来 awk ‘{print $0}’ test.txt 将test.txt中所有段打印出来 awk -F ‘:’ ‘{print $1,$2,$3}’ test.txt 将test.txt中第1,2,3段打印出来 awk -F ‘:’ ‘{print $1"#"$2"#"$3}’ test.txt 将...原创 2019-08-20 16:29:44 · 323 阅读 · 0 评论 -
shell脚本之for循环
#! /bin/bash for i in seq 1 100 do echo $i done #打印1到100 #!/bin/bash sum=0 for i in seq 1 100 do sum=[[[sum+$i] done echo $sum #求和,从1到100 [root@allen etc]# cat 456.sh #!/bin/bash cd /etc/ for a in l...原创 2019-08-31 11:32:16 · 376 阅读 · 0 评论 -
shell脚本之while循环
#!/bin/bash while true do load=w|head -1|awk -F 'load average: ' '{print $2}'|cut -d. -f1 #将系统负载复制到load变量中 if [ KaTeX parse error: Expected 'EOF', got '#' at position 87: … ...原创 2019-08-31 16:19:07 · 418 阅读 · 0 评论 -
shell脚本之break跳出循环 continue结束本次循环
#!/bin/bash for i in seq 1 5 do echo $i if [ $i -eq 3 ] #对数字进行比较用eq,字符串用== then break #当i等于3时,就跳出循环 fi echo $i done echo NBA [root@allen shell]# sh break.sh 1 1 2 2 3 NBA #!/b...原创 2019-09-02 18:41:20 · 1210 阅读 · 0 评论 -
shell脚本中的函数
[root@allen shell]# cat fun.sh #!/bin/bash function inp(){ echo “the first par is $1” echo “the second par is $2” echo “the third par is $3” echo “the scritp name is $0” echo “the number of par is $#”...原创 2019-09-03 11:12:23 · 130 阅读 · 0 评论 -
shell脚本之告警系统
(主目录) | | | | | bin conf ...原创 2019-09-06 16:12:28 · 386 阅读 · 0 评论 -
分发系统 expect详解
自动远程登录,并执行命令 [root@localhost sbin]# cat 1.expect #! /usr/bin/expect set host “10.1.1.135” set passwd “123456” spawn ssh root@KaTeX parse error: Can't use function '\r' in math mode at position 35: …no...原创 2019-09-24 10:29:43 · 246 阅读 · 0 评论