我有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 ] >

但是,为什么sed不在匹配模式后附加newline呢?
我该怎么附加它?

最佳答案

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

关于regex - 为什么sed不像awk那样添加换行符?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/29283922/

10-12 13:30