[英]How to replace multiline comments with sed in files
我有各種各樣的文件php html xml
,其中copyright
聲明包含在top
或從頂部起2-3行之后,像這樣
/**
* Copyright (c) 2014
* All rights reserved.
* bla bla many lines like this
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
現在我想從所有文件中刪除所有文本。
如何使用sed刪除。
我只知道基本的sed
但我不知道如何處理多行
$ cat file
1
2
/**
* Copyright (c) 2014
* All rights reserved.
* bla bla many lines like this
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
3
4
/* and here is another comment
* you presumably want to keep
*/
5
6
$ awk '/^\/\*/{c++} c!=1; /^ \*\//{c++}' file
1
2
3
4
/* and here is another comment
* you presumably want to keep
*/
5
6
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.