为什么sed没有像awk那样添加换行符?

时间:2015-03-26 16:30:59

标签: regex linux bash awk sed

我的example.css包含

http://www.example.com
/*
Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
/* // http:// .cke_reset{margin:0;padding:0;border:0;background:transparent;text-decoration:none;width:auto;height:auto;vertical-
/*
*Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.
*For licensing, see LICENSE.html or http://zoelabs.com/license

http://www.example3.com

*Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.
*For licensing, see LICENSE.html or http://zoelabs.com/license
*/



http://www.example2.com

我已成功使用反转匹配来过滤/**/之间的字符串 这是我的bash输出:

/ ZoeLabs / - [ moono ] > sed -n '/\/\*/,/\*\//!p' example.css
http://www.example.com



http://www.example2.com/ ZoeLabs / - [ moono ] >  

我希望输出

/ ZoeLabs / - [ moono ] > sed -n '/\/\*/,/\*\//!p' example.css
http://www.example.com



http://www.example2.com
/ ZoeLabs / - [ moono ] >

但是,为什么sednewline之类的匹配模式之后没有追加awk呢? 我该怎么做才能追加它?

1 个答案:

答案 0 :(得分:1)

sed ':a;$!N;$!ba;s/\/\*[^*]*\*\([^/*][^*]*\*\|\*\)*\///g' example.css|awk '{print}'