File 使用sed使所有注释保持一致
我的文件包含不均匀的注释:File 使用sed使所有注释保持一致,file,text,sed,File,Text,Sed,我的文件包含不均匀的注释: // file1.php // Week 4 // Quiz //coment3 // comment4 / /comment5 / /comment6 %comment7 % comment8 %comment9 #comment10 #
// file1.php
// Week 4
// Quiz
//coment3
// comment4
/ /comment5
/ /comment6
%comment7
% comment8
%comment9
#comment10
# comment11
#comment12
我想通过将
或/
替换为/
,后跟一个空格,使这些注释保持一致。我有:
s/[\t]*/
它给了我
// file1.php
// Week 4
// Quiz
//coment3
// comment4
/ /comment5
/ /comment6
#comment10
# comment11
#comment12
sed -e 's,/[[:space:]]*/,//,' -e 's,[[:space:]]*//[[:space:]]*,// ,' -e 's/[[:space:]]*\([%#]\)[[:space:]]*/\1 /'