Hi guru's,
I am trying to write a script to generate a csv file by connecting to database run a query and put the values into csv file.
But the problem i face is i am getting lot of space after one value.how can i remove those values?.
Please help.
#!/bin/bash
export comtdir=/opt/DataMig/data/name
export logdir=/opt/DataMig/data/name
export datadir=/opt/DataMig/data/name
export migpassword=tiger
sqlplus -s scott$HOST_CONNECT_STR/$migpassword <<EOF > ${logdir}/taxdetails.txt
set linesize 500
set feedback off
set heading off
select trim(A),trim(B),trim(C),trim(D),trim(E) from xyz
where rownum<4
order by B;
EOF
tr -s ' '<taxdetails.txt | tr ' ' ',' >taxdetails.csv
here first i am trying to create a txt file and convert it into csv file.
what i need to get:
disc,334567,11756,raj,W2
What i am getting:
disc ,334567 ,11756 ,raj W2