Tabs missing in batch mode

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

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 wrote:
Quoted text here. Click to load it

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"

Bill K.

Re: Tabs missing in batch mode

Thanks a lot, that caused the problem.

Site Timeline