Delete all comments in a file using sed

后端 未结 7 1258
情书的邮戳
情书的邮戳 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.

提交回复
热议问题