How can I comment out lines from a certain pattern and N lines onwards?
int var1;
int var2;
int var3;
int var4;
int var5;
I want to comment out 3 lines including var2 (and not according to their content!):
int var1;
// int var2;
// int var3;
// int var4;
int var5;
This requires GNU sed
sed '/^int var2;$/,+2 s.^.//.'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With