I am referring to this link
I have an output via this command:
mysql -e "show engine innodb status" -u -p database > mydumpfile.txt
However, any editor I use (less, vim, kwrite) is showing the \n
instead of a real new line.
How can I accomplish the replacement with sed, awk or any other tool in a shell?
You can use the following syntax of sed.
sed -i -e 's|\\n|\n|g' mydumpfile.txt
If you want the direct output properly from mysql then use --table option in mysql command.
mysql --table -e "show engine innodb status" -u -p database > mydumpfile.txt
Try simply adding \G
to the SQL command, for example:
mysql -e "show engine innodb status\G" -u -p database > mydumpfile.txt
Or try running the mysql client with the -r
(or --raw
) switch.
mysql -re "show engine innodb status" -u -p database > mydumpfile.txt
With either of these methods, you can also skip the intermediate file and just pipe into less
. Such as:
mysql -re "show engine innodb status" -u -p database | less
Side note, specifying the database is not necessary. I included it only for parity to your question. If you also have setup a my.cnf file, and therefore don't need to enter a password, you can shorten this to:
mysql -re "show engine innodb status" | less
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With