in reply to parsing a file
I am rather late to this party but assuming your records are all seperated by a single blank line and there are no superfluous blank lines then this rather obfu looking one liner will get you there
perl -pe'BEGIN{print"__BEGIN__\n"}s/^\s*$/__BEGIN__\n__END__\n/;END{pr +int"__END__\n"}' <file>
Or the mildly shorter but fiercly uglier
perl -pe'$e="__END__\n";BEGIN{$b="__BEGIN__\n";print$b}s/^\s*$/$b$e/;E +ND{print$e}' <file>
Cheers,
R.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: parsing a file
by Limbic~Region (Chancellor) on Jan 25, 2005 at 18:21 UTC |