[ale] Another Large File/PERL/Awk/Sed question...

Richard Bronosky Richard at Bronosky.com
Tue Dec 1 16:29:26 EST 2009


in sed, use '[range/line number]{commands}' to limit where the edits
are made. Example:
mount |sed '1{s/type/TEST/}'

what you want is:
sed -i.bak '1{s/column4/column5/}' filename

A backup filename.bak will be created with that command. drop the
-i.bak if you don't want it.


On Tue, Dec 1, 2009 at 4:06 PM, Bob Kruger <bkruger at mindspring.com> wrote:
> All;
>
> Thanks to all who assisted me with my earlier question on deleting the semicolon from the end of a line.  I have another one that may be a bit stickier.
>
> Again I have a large data file in text format, this one is 3.2GB.  Same as before, the field are semicolon delimited.  The first line of the file is the column name.  However, I have two columns that were inadvertently given the same column name.
>
> Example:
>
> column1;column2;column3;column4;column4;column6;column7....
>
> I would like to change the second instance of column4 to column5 on the first line of the file.  I thought it would be simple to fire up vi and just do a simple text edit.  The edit part was simple, but the saving of the file is taking hours.
>
> Any thoughts or ideas using PERL, Awk, or Sed?
>
> Thanks in advance for any assistance.
>
> V/r
>
> Bob
>
>
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://mail.ale.org/mailman/listinfo/ale
> See JOBS, ANNOUNCE and SCHOOLS lists at
> http://mail.ale.org/mailman/listinfo
>



-- 
.!# RichardBronosky #!.



More information about the Ale mailing list