Graceful view of MySQL GRANTS

Just found this script. It allows to output grants in graceful way:

mysql -B -N $@ -e "SELECT DISTINCT CONCAT(
'SHOW GRANTS FOR \'', user, '\'@\'', host, '\';'
) AS query FROM mysql.user" | \
mysql $@ | \
sed 's/\(GRANT .*\)/\1;/;s/^\(Grants for .*\)/## \1 ##/;/##/{x;p;x;}'

Output example:

## Grants for ping@localhost ##
GRANT USAGE ON *.* TO 'ping'@'localhost' IDENTIFIED BY PASSWORD '*123QWE123QWE123QWE123QWE123QWE123QWE123Q';

## Grants for monitoring@localhost ##
GRANT SUPER ON *.* TO 'monitoring'@'localhost' IDENTIFIED BY PASSWORD '*123QWE123QWE123QWE123QWE123QWE123QWE123Q';