shell脚本的日常使用

说明:该文章是日常使用shell脚本时常用命令和用法的总结,很多内容参考了其他博客,在此一并说明并感谢~


命令行中while的使用:

参考:http://blog.csdn.net/daoshuti/article/details/72831256

有时候想直接在命令行中写一个简单的监测脚步,监测某个参数的变化,可以用下面的语句:

死循环

命令格式:while : ;do <command>;done;

举例:

wanghan@ubuntu:~$ while : ;do echo "hello"; sleep 1; done;
hello
hello
hello
hello
hello
^C
wanghan@ubuntu:~$

普通计数循环

命令格式:mycount=0; while (( $mycount < 10 )); do  <command>;((mycount=$mycount+1)); done;

举例:

wanghan@ubuntu:~$ mycount=0; while (( $mycount < 10 )); do echo "mycount=$mycount"; ((mycount=$mycount+1)); done;
mycount=0
mycount=1
mycount=2
mycount=3
mycount=4
mycount=5
mycount=6
mycount=7
mycount=8
mycount=9


++++++++++++++++++++++++++++++

监控文件的持续更新

tail -f /var/log/dmesg

监控命令的持续输出

watch "dmesg | tail -20"




未完,待续。。。


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值