I'm trying to run the following command to generate a my.cnf
:
{
# Print version, user, host and time
echo -e "# MYSQL VARIABLES {{{1\n##\n# MYSQL `
mysql -V | sed 's,^.*\(V.*\)\, for.*,\1,'
` - By: `logname`@`hostname -f` on `date +%c`\n##"
for l in {a..z}; do
# Get mysql global variables starting with $l
echo '#'; mysql -NBe "SHOW GLOBAL VARIABLES LIKE '${l}%'" |
# Transorm it
sed 's,\t,^= ,' |
column -ts^ |
tr "\n" '@' |
eval $(echo "sed '" "s,@\("{a..u}{a..z}"\),\n\n\1,;" "'") |
eval $(echo "sed '" "s,@\(innodb_"{a..z}{a..z}"\),\n\n\1,;" "'") |
tr '@' "\n" |
sed 's,^,# ,g'
done
echo -e "#\n##\n# MYSQL VARIABLES }}}1";
} | tee ~/mysql-variables.log
(original source for command: http://www.askapache.com/mysql/view-mysql-variables-my-cnf.html )
However sed
keeps throwing an unterminated substitute pattern
error:
sed: 3: " s,@\(aa\),\n\n\1,; s,@ ...": unterminated substitute pattern
sed: 2: " s,@\(innodb_aa\),\n\n\ ...": unterminated substitute pattern
#
sed: 3: " s,@\(aa\),\n\n\1,; s,@ ...": unterminated substitute pattern
sed: 2: " s,@\(innodb_aa\),\n\n\ ...": unterminated substitute pattern
#
How can I cleanly output my current mysql variables?