How to pretty-print my.cnf with a one-liner

shell:

    awk -F= '! /(^#|^$)/ { if ($2 != "") printf "%-34s = %s\n", $1,$2; else printf "%s\n", $1 }' /etc/my.cnf  
    awk '! /(^#|^$)/ {printf “%-34s %s %s\n”, $1, $2, $3}' /etc/my.cnf 

Perl:

    perl -ne 'm/^([^#][^\s=]+)\s*(=.*|)/ && printf("%-35s%s\n", $1, $2)' /etc/my.cnf 

发表评论