tobold.org

correct • elegant • free

△ comp.lang.perl △

◅ Need to fork and exec and pipe!

How to Redirect STDOUT? ▻

Help with removing a line from a file

In article <4frb9h$rap@calvin.risq.qc.ca>,  <dgi048@sgo.gouv.qc.ca> wrote:
>I'm writing a perl script and I want to remove a line from the /etc/aliases file.

This will remove any line that begins with the characters `tim:',
keeping the old file as /etc/aliases.bak.

    perl -ni.bak -e 'print unless /^tim:/' /etc/aliases

See the perlrun manpage for the meanings of the `-n' and `-i'
switches, which are doing most of the hard work here.

Tim.
--
Tim Goodwin   | "I just noticed that a SUN SLC takes longer to
UUnet PIPEX   | get to its boot prompt than it takes to build
Cambridge, UK | its [ Plan 9 ] kernel." -- Phil Winterbottom

Original headers:

From: tim@pipex.net (Tim Goodwin)
Newsgroups: comp.lang.perl.misc
Subject: Re: Help with removing a line from a file
Date: 14 Feb 1996 17:30:01 GMT
Organization: Unipalm PIPEX
Message-ID: <4ft66p$h23@wave.news.pipex.net>
References: <4frb9h$rap@calvin.risq.qc.ca>

△ comp.lang.perl △

◅ Need to fork and exec and pipe!

How to Redirect STDOUT? ▻