Shell Script to remove spaces while writing to the file

Hello Folks,
I want to get the results from a SQL query which needs to be exported to a .txt file.
My Script is something like

#!/bin/ksh
db2 connect to DATABASE user user_name using pwd;
touch test.txt
isResult=0;
isResult= `db2 -x select 'ABC',COL_B from TABLE_A WHERE COL_B=CONDITION`
print "$isResult" >> test.txt
echo Done

So in the test.txt I am getting the output as
ABC_COLBDATA
ABC_COLBDATA
ABC_COLBDATA
ABC_COLBDATA

WhiteSpace is marked as _
My question is that How can I remove the space between each column. While writing on to the output file,Space is automically getting populated between each column. Please help me on this. Thanks in advance!!

| tr -d ' '  
| tr ' ' ''   

Thanks Chakra!! but i am a new bee.. could you please tell me where to use this part of code in my above script

try this: notice there is a space in between ' single quote

print "$isResult" | tr -d ' ' >> test.txt

awk should work as well:

print "$isResult" | awk '{ print $1 $2 }' >> test.txt

The following too will work -


tr -d ' ' < test.txt > newtest.txt

Thanks a lot guys!!!!

---------- Post updated at 04:24 AM ---------- Previous update was at 04:08 AM ----------

The issue of single space between each column is resolved.
But there is one more catch here. There is column value which contains eight blank spaces which needs to be printed.

Something like this..

ABC_COLBDATA---------COLCDATA
ABC_COLBDATA---------COLCDATA
ABC_COLBDATA---------COLCDATA

_ is blankspace between the columns

  • is the null values from the table data.
    Hope you understand my explanation

---------- Post updated at 04:31 AM ---------- Previous update was at 04:24 AM ----------

got it guys!!!

awk '{print $1 $2 "        " $3 $4}'