一行 Perl 的命令, 格式化印出 my.cnf 檔, 同樣做法, 也可以用在其它 conf file.(ex: php.ini)
指令
- perl -ne 'm/^([^#][^\s=]+)\s*(=.*|)/ && printf("%-35s%s\n", $1, $2)' /etc/mysql/my.cnf
執行結果
- [client]
- port = 3306
- socket = /var/run/mysqld/mysqld.sock
- [mysqld_safe]
- socket = /var/run/mysqld/mysqld.sock
- nice = 0
- [mysqld]
- user = mysql
- pid-file = /var/run/mysqld/mysqld.pid
- socket = /var/run/mysqld/mysqld.sock
- port = 3306