shell


[root@iz2ze8gfe049j7ehtvstv7z aaa]# cd /home/song/aaa/ ; ls -lrt
total 392
-rw-r--r-- 1 root root 396866 Jul 21 15:55 dist.tar.gz
-rw-r--r-- 1 root root      0 Jul 29 14:26 aa
-rw-r--r-- 1 root root      0 Jul 29 14:26 123
drwxr-xr-x 2 root root   4096 Jul 29 14:26 a
[root@iz2ze8gfe049j7ehtvstv7z aaa]#
[root@iz2ze8gfe049j7ehtvstv7z aaa]#
[root@iz2ze8gfe049j7ehtvstv7z aaa]# cd /home/song/aaa/ ; for i in *; do [ $i == dist.tar.gz ]|| rm -rf $i;done
[root@iz2ze8gfe049j7ehtvstv7z aaa]#
[root@iz2ze8gfe049j7ehtvstv7z aaa]#
[root@iz2ze8gfe049j7ehtvstv7z aaa]#
[root@iz2ze8gfe049j7ehtvstv7z aaa]#
[root@iz2ze8gfe049j7ehtvstv7z aaa]# ls -lrt
total 388
-rw-r--r-- 1 root root 396866 Jul 21 15:55 dist.tar.gz


cat a.txt | awk 'NR>1' | while read name number
do
    echo $name
    echo $number
done
[root@iz2ze8gfe049j7ehtvstv7z ~]# while true ; do for i in  {baidu.com,sina.com.cn,blog.csdn.net};do echo  `date`  ;curl $i ;done && sleep 1; done
Thu Aug 19 15:07:44 CST 2021
<html>
<meta http-equiv="refresh" content="0;url=http://www.baidu.com/">
</html>
Thu Aug 19 15:07:44 CST 2021
<html>
<head><title>301 Moved Permanently</title></head>
<body bgcolor="white">
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx</center>
</body>
</html>
Thu Aug 19 15:07:44 CST 2021
<html>
<head><title>301 Moved Permanently</title></head>
<body>
<center><h1>301 Moved Permanently</h1></center>
<hr><center>openresty</center>
</body>
</html>

shell显示ok或fail — action:

[root@iz2ze8gfe049j7ehtvstv7z song]# cat a.sh
#! /bin/bash
. /etc/init.d/functions         #需要提前声明 ,加载系统函数库
mkdir /home/song/tkdz
if [ $? -eq 0 ]
  then
     echo "zhengchang"
     action "nimeide" /bin/true
  else
     echo "buzhengchang"
     action "gano" /bin/false
fi

echo "zhe shi yige fenge=============================="
if [ $? -eq 0 ]
  then
     echo "zhengchang"
     action "nimeide" /bin/true
  else
     echo "buzhengchang"
     action "gano" /bin/false
fi

[root@iz2ze8gfe049j7ehtvstv7z song]#
[root@iz2ze8gfe049j7ehtvstv7z song]#
[root@iz2ze8gfe049j7ehtvstv7z song]# bash a.sh
mkdir: cannot create directory ‘/home/song/tkdz’: File exists
buzhengchang
gano                                                       [FAILED]
zhe shi yige fenge==============================
zhengchang
nimeide                                                    [  OK  ]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值