码迷,mamicode.com
首页 > 其他好文 > 详细

awk小结

时间:2016-05-04 20:59:34      阅读:143      评论:0      收藏:0      [点我收藏+]

标签:

 

[root@lanny ~]# chkconfig --list|grep 3:on
atd                0:off    1:off    2:on    3:on    4:on    5:on    6:off
crond              0:off    1:off    2:off    3:on    4:off    5:off    6:off
network            0:off    1:off    2:off    3:on    4:off    5:off    6:off
rsyslog            0:off    1:off    2:off    3:on    4:off    5:off    6:off
sshd               0:off    1:off    2:off    3:on    4:off    5:off    6:off
sysstat            0:off    1:on    2:off    3:on    4:off    5:off    6:off

 

chkconfig 批量启动服务(使用循环)

输出列:awk {print $1}

输出第一列

 

批量操作:两种思想:

1,先全关掉,开启需要开启的

[root@lanny ~]# chkconfig --list|grep 3:on|awk {print $1}
atd
crond
network
rsyslog
sshd
syssta
 
对结果进行循环
for name in `chkconfig --list|grep 3:on|awk {print $1}`;do chkconfig $name on;done

 

2,关掉需要关的.

先全部打开

然后将想要排除的,用egrep -v排除掉.

然后批量关闭

chkconfig --list|grep 3:on|awk {print $1}|egrep -v crond|sshd|network|rsyslog
[root@lanny ~]# for name in `chkconfig --list|grep 3:on|awk {print $1}|egrep -v crond|sshd|network|rsyslog`;do chkconfig $name off;done
[root@lanny ~]# chkconfig --list|grep 3:on
crond              0:off    1:off    2:on    3:on    4:on    5:on    6:off
network            0:off    1:off    2:on    3:on    4:on    5:on    6:off
rsyslog            0:off    1:off    2:on    3:on    4:on    5:on    6:off
sshd               0:off    1:off    2:on    3:on    4:on    5:on    6:off

 

awk小结

标签:

原文地址:http://www.cnblogs.com/iiiiher/p/5459617.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!