Must the solution use
sed?
An
awk solution may run faster and be more readable.
With this InFile ...
Code:
Local server1
Local server2
Local server3
lucy
bill
Local server4
Local server5
lucy
john
Local server 6
... this
awk ...
Code:
awk 'FNR==1 {getline nextline <FILENAME}
{getline nextline <FILENAME; thisline=$0;
if (substr(thisline,1,5)!="Local" ||
substr(nextline,1,5)!="Local") print thisline}' \
$InFile >$OutFile
... produced this OutFile ...
Code:
Local server3
lucy
bill
Local server5
lucy
john
Daniel B. Martin