为什么 sed 不像 awk 那样追加换行符?
Why sed doesn't append newline like awk?
我有 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
不像 awk
那样在匹配模式后附加 newline
?
我应该怎么做才能附加它?
sed ':a;$!N;$!ba;s/\/\*[^*]*\*\([^/*][^*]*\*\|\*\)*\///g' example.css|awk '{print}'
我有 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
不像 awk
那样在匹配模式后附加 newline
?
我应该怎么做才能附加它?
sed ':a;$!N;$!ba;s/\/\*[^*]*\*\([^/*][^*]*\*\|\*\)*\///g' example.css|awk '{print}'