Delete all comments in a file using sed

后端 未结 7 1249
情书的邮戳
情书的邮戳 2020-12-17 00:14

How would you delete all comments using sed from a file(defined with #) with respect to \'#\' being in a string?

This helped out a lot except for the string portion.

相关标签:
7条回答
  • 2020-12-17 01:12
    sed 's:^#\(.*\)$:\1:g' filename
    

    Supposing the lines starts with single # comment, Above command removes all comments from file.

    0 讨论(0)
提交回复
热议问题