In the following script, I try to get all tables name from a mysql database and I expect all table's name printed out, but no matter what I do or which method I use, it just doesn't work. the printed string I suppose are tables name overlapped on each other:
mysql -Nse 'show tables' DATABASE |
while read table
Could it be that
mysql separates the table names by
\n\r instead of
read would then read
\rSecond Table, and so on. In most linux terminals
\r causes the cursor to jump back to the start of the current line.
ABC\r_ will be printed as
mysql -Nse 'show tables' DATABASE | sed 's:\r:\\r:' and look at the output. The control character
\r will be printed as the literal string
... | tr -d '\r' | ... between the commands.