line processing slow



Hi,

I've a data file with 1million lines. Eg.

aaaaabbbbbbccccddd <- fix column
........
.......

I wanted to insert a comma ','.

This is what i did:

cat $inputfile | while read line
do
field1=`echo $line | cut -c1-5`
field2=`echo $line |cut -c6-11`
field3=`echo $line |cut -c12-15`
echo ${field1},${field2},${field3} >> outputfile
done

for 1million lines, the processing is painful.

Is there any more efficient way of doing the input/output?

Thanks and regards


.



Relevant Pages

  • Re: line processing slow
    ... I've a data file with 1million lines. ... I wanted to insert a comma ','. ... cat $inputfile | while read line ...
    (comp.unix.shell)
  • Re: line processing slow
    ... I've a data file with 1million lines. ... I wanted to insert a comma ','. ... cat $inputfile | while read line ...
    (comp.unix.shell)
  • Re: line processing slow
    ... I've a data file with 1million lines. ... I wanted to insert a comma ','. ... cat $inputfile | while read line ...
    (comp.unix.shell)
  • Re: ms grammar checker rubbish redux
    ... course with Professor William S. Strunk Jr. ... If the clauses are very short, and are alike in form, a comma is ... What about the reasons ... go be a hep cat of the ...
    (alt.usage.english)
  • Re: [Info-ingres] writing VARCHAR strings including the backslash character into the database as
    ... What you are seeeing displayed when you do a select teamnameregex is simply an artifact of SQL trying to show the '\' is not a pure escape character. ... If you try a copydb -c and cat the data file you'll see the data is genuinly stored as '\d' ... Random Duckman Quote #22: ...
    (comp.databases.ingres)