當我在一台服務器上轉悠時,我會經常想看看/etc/my.cnf文件格式,當然是想看格化美觀,沒有注釋的。這樣的一行Perl就能將美化輸出文件:
1.perl -ne ‘m/^([^#][^\s=]+)\s*(=.*|)/ && printf(”%-35s%s\n”, $1, $2)’ /etc/my.cnf
2.[client]
3.port = 3306
4.socket = /var/run/mysqld/mysqld.sock
5.[ mysqld_safe ]
6.socket = /var/run/mysqld/mysqld.sock
7.nice = 0
8.[ mysqld ]
9.user = mysql
10.pid-file = /var/run/mysqld/mysqld.pid
11.socket = /var/run/mysqld/mysqld.sock
12.port = 3306
13…..