Quantcast
Channel: dBforums – Everything on Databases, Design, Developers and Administrators
Viewing all articles
Browse latest Browse all 13329

Using output of db2 command line in shell

$
0
0
Hallo everyone,

I am running this command line for my shell variable:


Code:

myVar="$(db2 -x "select count(*) from mySchema.myTable")"
Let´s say, the output is one --> 1

I wanted to use this number for my case construction:

Code:

case $myVar in
0 )
.... ;;
1 )
.... ;;
esac

But it did not work. I was wondering why, and then I found a possible reason:

If I echo myVar, it gives me the correct answer:

Code:

echo ${myVar}
1


But if I echo something with myVar inside, it gives me the REAL structure of myVar, which are some white spaces:
Code:

echo "word $myVar"
word              1

I assume, this is why I cant use myVar in my case structure. Somebody any idea how to solve this problem.


I have try:
Code:

... | tr -d  ' '
It also didnt work.

Regards,

Ratna

Viewing all articles
Browse latest Browse all 13329

Trending Articles