0
votes

I have the below script

mysql -uleuser -plepassword -a ledb -e "select dr.order_id, dr.system_name from tschedule drtv where dr.system_name not in (select system_name from ca_tmc_site);" > $baselogdir/$datelogdir/$logfilename

the csv file(logfilename.csv) which is extracting is not in correct format

It gets messy and all mixed up for just two columns,is it because of the tab or spaces?

1

1 Answers

0
votes

try this: mysql -uleuser -plepassword -a ledb -ss -e "select dr.order_id, dr.system_name from tschedule drtv where dr.system_name not in (select system_name from ca_tmc_site);" | sed "s/'/\'/;s/\t/\",\"/g;s/^/\"/;s/$/\"/;s/\n//g” > $baselogdir/$datelogdir/$logfilename