[svlug] edit a 1GB file

William R Ward bill at wards.net
Mon Mar 31 09:38:59 PST 2003


Rufoo writes:
>
>--- Will Lowe <harpo at thebackrow.net> wrote:
>> > > It's a text file and I search for a line
>> matching some pattern and
>> > > replace it with a different line.  I really only
>> do this once in a
>> 
>> > Use grep(1) to find the line that you want to
>> change, use split(1) to
>> > cut the files down to a manageable size, use
>> vim(1) to edit the data,
>> > and then use cat(1) to join everything back to
>> together again.
>> 
>> or perhaps:
>> 
>> perl -pi -e 's/^some line$/some other line/g'
>> 
>> "man perlrun" for more.
>
>Why even perl when sed can do the same. 

How?  To the best of my knowledge, the equivalent in sed would require
adding a redirect and a "mv" command.  That's not just sed, that's
sed, shell, and mv.  Perl lets you do it in one command.

--Bill.

-- 
William R Ward            bill at wards.net          http://www.wards.net/~bill/
-----------------------------------------------------------------------------
"A foolish consistency is the hobgoblin of little minds, adored by
 little statesmen and philosophers and divines."        - Emerson



More information about the svlug mailing list