in reply to In place file modification

Seems like a lot of trouble only for this. Any other solution?
It just seems like a lot of work because you wrote it in English instead of (perl) code. Also, writing the output somewhere else and then replacing the original is safer (and much less work) than modifying the original file in place.

If you have enough memory you can probably do it in one or two lines of code. But I suspect this is homework, so I'm not going to elaborate. See the -i & -p & -0 flags

updated: forgot to add the -0 flag.

Replies are listed 'Best First'.
Re^2: In place file modification
by RaduH (Scribe) on Nov 01, 2007 at 15:18 UTC
    Hi Joost,

    I wish this was homework. I've been out of school for enough years not to get upset by the word "homework" anymore :). The "enough memory" solution I know, but I would rather avoid. I've learned the lesson "64k should be enough for everybody" soon after is was said :), so I am trying to avoid getting my head into this gutter.

    The real application for this is messing with /etc/fstab file and changing the location where some partitions are mounted (i.e., flip two partitions). I made up the Name-Address simplified example so the discussions won't get off track and discuss the Unix problem rather than my Perl question.

    Thanks for your suggestion, I'll look at that link!