Output Formatting

Hi Guys

I need help removing some lines from output i am receiving from a shell script.
Here is the output:

I am trying to remove the output that i have circled.

. ${EDW}/extracts/bin/extracts_setup2.sh
. ${EDW}/extracts/extracts.conf

date_f=`date +%Y%m%d` 
DATADIR=/extracts/
OUTFILE=article.$date_f   ; rm -f $OUTFILE
OUTFILEgo=article$date_f ; rm -f $OUTFILEgo

isql -U${USER} -P${PASSWD} -S${SERVER} > ${DATADIR}${OUTFILE} << EOF
go
select rtrim(departmentDescr)+ ','+ rtrim(categoryDescr)+ ','+ rtrim(brandDescr)+ ','+ 
convert(varchar,barcode)+ ','+ convert(varchar,uot)+ ','+ convert(varchar,skuId)+ ','+ rtrim(uotDescr)+ ','+ 
rtrim(convert(varchar,convert(int, uomQty))||uomDescr)
from DBA.DimProduct, DBA.BarcodeUot
where uot = unitOfTradeId
and uotDescr not like 'DISCONTINUED%'
and divisionDescr in ('FOODS', 'HARDS','SOFTS','PERISH')
order by departmentDescr, categoryDescr, skuId
go
EOF

cd ${DATADIR}

echo 'Department Description,Category Description,Brand Description,Barcode,Unit Of Trade,Sku Id,Unit Of Trade Description,Unit Of Measurement Qty' >>$OUTFILEgo


cat $OUTFILE |sed '/^$/d;/affected/d;s/  *$//' >> $OUTFILEgo


sed '
s/|$//g
s/"//g ' $OUTFILEgo > $OUTFILE
mv $OUTFILE $OUTFILEgo
gzip -9 $OUTFILEgo


cat $OUTFILE |grep -v 'rows affected' >> $OUTFILEgo


rm -f $OUTFILE
rm -f $OUTFILEgo

Thanks :rolleyes:

Won't this work?

sed 's/-//g' file

regards,
Ahamed

---------- Post updated at 12:20 AM ---------- Previous update was at 12:17 AM ----------

To remove the blank lines also

sed 's/-//g' file | awk '$0!="" {print}'

regards,
Ahamed

---------- Post updated at 12:21 AM ---------- Previous update was at 12:20 AM ----------

Even better

awk '!/^-/{print}' file

:wink:

regards,
Ahamed

1 Like

another one

sed '/-/d' yourfile

---------- Post updated at 10:28 AM ---------- Previous update was at 10:26 AM ----------

If you just want remove line 2 and 3 :

sed '2,3d' yourfile
1 Like

---------- Post updated at 03:33 AM ---------- Previous update was at 03:33 AM ----------

Thanks ill try that.

sed '/-/d;/rtrim/d' yourfile
1 Like

Thanks that worked perfectly.
1 question: I have a blank space before "3RD Party". I put the code below in but it removes all the blank spaces in the file whereas i was the leading spaces on each row removed so
" 3RD Party" becomes "3RD Party"

sed '/ /d' yourfile
sed '/-/d;/rtrim/d;s/^  *//' yourfile
1 Like

:smiley: Thanks working perfectly.