Sunday, 15 June 2014

Comment out N lines with sed/awk -


How can I comment lines from a certain pattern and n lines?

  int var1; Int var2; Int var3; Int var4; Int var5;  

I want to comment on 3 lines including var2 (and not according to their content!):

  int var1; // int var2; // in var3; // int var4; Int var5;  

GNU sed

  sed '/ ^ int var2; $ /, + 2s ^ // '  

No comments:

Post a Comment