How to edit a txt file ?
Hi,
I need to edit a text file which is like this..
Code:
-- D3341000600 AGEC901164 XYZ SE0109 1RNVX AH 2009-01-19 2009-01-11 2009-01-21
-- D3341000600 AGEC901164 XYZ SE0109 1RNVX AH 2009-01-19 2009-01-11 2009-01-21
-- D3341006000 AGEC921472 XYZ SE0109 1RNVX AH 2009-01-19 2009-01-11 2009-01-21
-- D3341006000 AGEC921472 XYZ SE0109 1RNVX AH 2009-01-19 2009-01-11 2009-01-21
-- D3213716600 DCEC160720 XYZ RZ9191 1RNVX AH 2009-01-19 2009-01-11 2009-01-21
-- D3213716600 DCEC160720 XYZ RZ9191 1RNVX AH 2009-01-19 2009-01-11 2009-01-21
-- D3213716300 DCEC169043 XYZ RZ9191 1RNVX AH 2009-01-19 2009-01-11 2009-01-21
-- D3213716300 DCEC169043 XYZ RZ9191 1RNVX AH 2009-01-19 2009-01-11 2009-01-21
-- D3213716100 DCEC197234 XYZ RZ9191 1RNVX AH 2009-01-19 2009-01-11 2009-01-21
-- D3213716100 DCEC197234 XYZ RZ9191 1RNVX AH 2009-01-19 2009-01-11 2009-01-21
I need to get it like this..
Code:
D3341000600|AGEC901164 XYZ|SE0109|1RNVX|AH|2009-01-19|2009-01-11|2009-01-21
D3341000600|AGEC901164 XYZ|SE0109|1RNVX|AH|2009-01-19|2009-01-11|2009-01-21
D3341006000|AGEC921472 XYZ|SE0109|1RNVX|AH|2009-01-19|2009-01-11|2009-01-21
D3341006000|AGEC921472 XYZ|SE0109|1RNVX|AH|2009-01-19|2009-01-11|2009-01-21
D3213716600|DCEC160720 XYZ|RZ9191|1RNVX|AH|2009-01-19|2009-01-11|2009-01-21
D3213716600|DCEC160720 XYZ|RZ9191|1RNVX|AH|2009-01-19|2009-01-11|2009-01-21
D3213716300|DCEC169043 XYZ|RZ9191|1RNVX|AH|2009-01-19|2009-01-11|2009-01-21
D3213716300|DCEC169043 XYZ|RZ9191|1RNVX|AH|2009-01-19|2009-01-11|2009-01-21
D3213716100|DCEC197234 XYZ|RZ9191|1RNVX|AH|2009-01-19|2009-01-11|2009-01-21
D3213716100|DCEC197234 XYZ|RZ9191|1RNVX|AH|2009-01-19|2009-01-11|2009-01-21
I tried with this code.. but its not working.. the script is not terminating.. and the log file is empty..
Code:
#!/bin/ksh
for name in `cat data.txt`
do
cat $name |cut -f2,3,4,5,6,7,8,9|tr '\t' '|' > processed_data.txt
done
if [ $? -eq 0] ; then echo " Prcocessing completed."
else echo "script failed"
fi
Please help..
Thanks,
RRVARMA
|