第一步:把要执行命令的样子显示出来

[root@oldboyedu-39 ~]# chkconfig|egrep "sshd|crond|rsyslog|network|sysstat"|sed -r 's#(^.*)0.*#chkconfig \1 on#g' 

chkconfig crond           on

chkconfig network         on

chkconfig rsyslog         on

chkconfig sshd           on

chkconfig sysstat         on

第二步:把要执行命令的样子显示出来并且执行

[root@oldboyedu-39 ~]# chkconfig|egrep "sshd|crond|rsyslog|network|sysstat"|sed -r 's#(^.*)0.*#chkconfig \1 on#g'|bash

第三步:查看执行的结果

[root@oldboyedu-39 ~]# chkconfig|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

sysstat         0:off 1:on 2:on 3:on 4:on 5:on 6:off