After installing a new system, some boot-start services need to be shut down in order to simplify the system.
The snail uses the basic commands of grep and awk to operate.
As a server, the service that needs to be started in the new system is probably the following
Crond Network sshd Rsyslog
Viewing runlevel 3 boot-up services
Chkconfig--list|grep 3:on
650) this.width=650; "Src=" https://s5.51cto.com/wyfs02/M00/A4/3E/wKioL1mnaRKSUKGBAACJJTszOTk109.png-wh_500x0-wm_ 3-wmp_4-s_319818434.png "style=" Float:none; "title=" Image.png "alt=" wkiol1mnarksukgbaacjjtszotk109.png-wh_50 "/ >
Step 1: Collect the service name
Use grep to filter out the 3:on service, then exclude the four options for Crond network sshd rsyslog, then utility awk outputs the first column of content
Chkconfig--list|grep 3:on|grep-ev "Network|sshd|crond|rsyslog" |awk ' {print $} '
650) this.width=650; "Src=" https://s3.51cto.com/wyfs02/M00/A4/3E/wKioL1mnaRKy2axEAAA-Hozzx5k703.png-wh_500x0-wm_ 3-wmp_4-s_1109712849.png "style=" Float:none; "title=" Image1.png "alt=" wkiol1mnarky2axeaaa-hozzx5k703.png-wh_50 "/ >
Here's a practical awk-based operation, which describes one of awk's parameters-F after adding a field delimiter to use after using fields like $ $ $ and so on to filter if you don't use the-F default delimiter as a space, the above operation directly uses the contents of the output after
The whole row is the first column.
650) this.width=650; "Src=" https://s3.51cto.com/wyfs02/M02/05/8D/wKiom1mnaSiQretSAAOe73sJOsQ025.png-wh_500x0-wm_ 3-wmp_4-s_2952377833.png "style=" Float:none; "title=" Image2.png "alt=" wkiom1mnasiqretsaaoe73sjosq025.png-wh_50 "/ >
Step 2: Combine the captured data into a command and bash
Chkconfig--list|grep 3:on|grep-ev "Network|sshd|crond|rsyslog" |awk ' {print $} ' |awk ' {print ' chkconfig ' $ ' off '} ' |bas H
It is important to note that the trailing and off of the chkconfig must be preceded by a space that is combined with the awk variable and sent to bash for processing
The operation results are as follows
650) this.width=650; "Src=" https://s3.51cto.com/wyfs02/M00/05/8D/wKiom1mnaSnAyCeFAAA7ufic8yY717.png-wh_500x0-wm_ 3-wmp_4-s_1618460001.png "style=" Float:none; "title=" Image4.png "alt=" wkiom1mnasnaycefaaa7ufic8yy717.png-wh_50 "/ >
It's just a simple practical way to use Awk's other powerful features and continue writing ...
This article is from the "relentless snail" blog, please be sure to keep this source http://songxiao.blog.51cto.com/12183698/1961289
Linux awk command bulk shutdown system boot-up service