Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- Tabs missing in batch mode
April 24, 2006, 3:28 pm
rate this thread
in a shell script of mine I'm executing a mysql SELECT in batch mode. I
want to use the return value for other sql statements.
The problem I'm facing is that the tabs, which seperate the columns
from each other, are missing in the output.
What am I doing wrong?
QUERY="select id, i.handle from idmap i, person p where
i.handle=p.handle and email=\"$1\""
mysql mydatabase -pmypassword -N -B -e "$QUERY" | while read line ; do
personid=$(echo $line | cut -f1) ; handle=$(echo $line | cut -f2 ) ;
echo $handle ; done ;
Re: Tabs missing in batch mode
Try echo "$line" instead of echo $line. The whitespace is being
interpreted by the shell. The shell interprets any amount of whitespace
as equivalent to one space, unless you protect it with quoting.
For example, try the following, typing a tab character where I indicate
$ echo one \t two \t three
Now try it with quotes:
$ echo "one \t two \t three"
- » Dynamically construct and execute SQL in StoredProcedure
- — Previous thread in » MySQL Database Forum
- » Americanas.com SALDO de TVs Com at 80% de Desconto (29798)
- — Newest thread in » MySQL Database Forum