470,643 Members | 1,364 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,643 developers. It's quick & easy.

Tabs missing in batch mode

Hi,

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?

#!/bin/sh
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 ;
Fritz

Apr 24 '06 #1
2 1237
fr*********@web.de wrote:
Hi,

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?

#!/bin/sh
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 ;


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
"\t" below:

$ echo one \t two \t three

Now try it with quotes:

$ echo "one \t two \t three"

Regards,
Bill K.
Apr 24 '06 #2
Thanks a lot, that caused the problem.

Apr 25 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

12 posts views Thread by Moosebumps | last post: by
5 posts views Thread by Tyler Hudson | last post: by
12 posts views Thread by Selva Chinnasamy | last post: by
135 posts views Thread by Xah Lee | last post: by
35 posts views Thread by Ben | last post: by
1 post views Thread by Korara | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.