【问题标题】:use sed to make all comments consistent使用 sed 使所有注释保持一致
【发布时间】:2021-01-13 15:11:23
【问题描述】:

我的文件包含不均匀的 cmets:

// file1.php
        // Week 4 
        // Quiz
                               //coment3
//                     comment4
/ /comment5
      / /comment6
%comment7
%               comment8
                           %comment9
#comment10
#                     comment11
            #comment12

我想通过将 #// 替换为 // 后跟一个空格来使这些 cmets 保持一致。
我有:s/[ \t]*//.
它给了我

// file1.php
// Week 4 
// Quiz
//coment3
//                     comment4
/ /comment5
/ /comment6
#comment10
#                     comment11
#comment12

【问题讨论】:

    标签: file text sed


    【解决方案1】:
    sed -e 's,/[[:space:]]*/,//,' -e 's,[[:space:]]*//[[:space:]]*,// ,' -e 's/[[:space:]]*\([%#]\)[[:space:]]*/\1 /'
    

    【讨论】:

      猜你喜欢
      • 2011-06-15
      • 1970-01-01
      • 2012-11-12
      • 1970-01-01
      • 1970-01-01
      • 2017-12-24
      • 2018-09-06
      • 2017-10-20
      • 1970-01-01
      相关资源
      最近更新 更多