home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!noc.near.net!hri.com!spool.mu.edu!caen!destroyer!gumby!wupost!cs.utexas.edu!sun-barr!male.EBay.Sun.COM!jethro.Corp.Sun.COM!jethro!eric
- From: eric@animus.Corp.Sun.COM (eric )
- Newsgroups: comp.lang.perl
- Subject: Re: Delete until pattern match
- Message-ID: <ERIC.92Dec11142621@animus.Corp.Sun.COM>
- Date: 11 Dec 92 19:26:21 GMT
- References: <3722@symbas.UUCP>
- Organization: /home1/eric1/.organization
- Lines: 25
- NNTP-Posting-Host: animus.corp.sun.com
- In-reply-to: hans@symbas.UUCP's message of 11 Dec 92 18:46:09 GMT
-
- In article <3722@symbas.UUCP> hans@symbas.UUCP (Hans Aafloy) writes:
-
- > From: hans@symbas.UUCP (Hans Aafloy)
- >
- > I have some files in which I want to delete all lines until a
- > certain pattern match. I know a couple of awkward ways to do it,
- > ( using an array as temporary storage etc.)
- > but is there a quicker and more elegant solution ?
- >
- > Thanx for any hints - via e-mail please.
- >
- > Hans
- >
- > hans@symbas.lind.no
-
- I think this is exactly what I was just asking about a few message ago. The
- answer is:
-
- perl -ni.old -e 'print unless ( 1 .. /^---cut here---/ ); close(ARGV) if eof' file1 file2
-
- What this does it go through all files ("file1", "file2", etc.), and
- remove everything up to and including the pattern "---cut here---", and
- rename the original file "file1.old", etc.
-
- -Eric
-