in reply to script for removing certain text

If you want to remove the beginning and end lines as well, you can do this as a one-liner, editing the fields in place:

perl -nie "print unless /begin/../end/" file1 file2

Of course, the details of quoting, etc. are up to your shell (like for instance, you'd use " instead of ' under Windows shells).

If you want backup files to be made, do this:

perl -ni.bak -e "print unless /begin/../end/" file1 file2

This will make backup files that are named file1.bak and so on.

Replies are listed 'Best First'.
Re: Re: script for removing certain text
by Anonymous Monk on Jun 29, 2001 at 19:39 UTC
    Hi Nomad, I tried your command, but it says "Can't open perl script "print unless /specify/../endspecify/": No such file or directory"..... Any guess. Thanks J