Reputation: 13195
I have the following script to strip a license region from a file, but I am left with a blank line at the beginning.
perl -pi~ -ne 'if (/#region License/../#endregion/) {$_ = "" if ($. == 1 || $. == 2)}' $i
Upvotes: 2
Views: 592
Reputation: 385789
perl -i~ -ne'
next if /#region License/../#endregion/;
next if !$body && /^\s+\z/;
++$body;
print;
' "$i"
Feel free to remove the line breaks, although it will work with them. They're there for readability.
Upvotes: 4