Chinaunix

标题: 文本处理求助-从文本中删除指定段落 [打印本页]

作者: bikkuri    时间: 2016-11-27 17:53
标题: 文本处理求助-从文本中删除指定段落
大家好!
我有一个问题向大家请教。
有以下一个文本。
spawn /usr/bin/ssh -l admin 135.240.146.101
The authenticity of host '135.240.146.101 (135.240.146.101)' can't be established.
RSA key fingerprint is 0a:d6:44:2c:00:74:f0:ad:43:73:47:89:0a:e1:3e:16.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '135.240.146.101' (RSA) to the list of known hosts.
TiMOS-C-11.0.R7 cpm/hops ALCATEL SR 7750 Copyright (c) 2000-2014 Alcatel-Lucent.
All rights reserved. All use subject to applicable license agreements.
Built on Tue Jan 14 14:19:43 PST 2014 by builder in /rel11.0/b1/R7/panos/main
admin@135.240.146.101's password:
A:NS101461484#
A:NS101461484# show time
Sun Nov 27 16:38:01 UTC 2016
A:NS101461484#
spawn /usr/bin/ssh -l admin 135.240.146.101
The authenticity of host '135.240.146.101 (135.240.146.101)' can't be established.
RSA key fingerprint is 0a:d6:44:2c:00:74:f0:ad:43:73:47:89:0a:e1:3e:16.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '135.240.146.101' (RSA) to the list of known hosts.
TiMOS-C-11.0.R7 cpm/hops ALCATEL SR 7750 Copyright (c) 2000-2014 Alcatel-Lucent.
All rights reserved. All use subject to applicable license agreements.
Built on Tue Jan 14 14:19:43 PST 2014 by builder in /rel11.0/b1/R7/panos/main
admin@135.240.146.101's password:
A:NS101461484#
A:NS101461484# show version
TiMOS-C-11.0.R7 cpm/hops ALCATEL SR 7750 Copyright (c) 2000-2014 Alcatel-Lucent.
All rights reserved. All use subject to applicable license agreements.
Built on Tue Jan 14 14:19:43 PST 2014 by builder in /rel11.0/b1/R7/panos/main
A:NS101461484#
spawn /usr/bin/ssh -l admin 135.240.146.101
The authenticity of host '135.240.146.101 (135.240.146.101)' can't be established.
RSA key fingerprint is 0a:d6:44:2c:00:74:f0:ad:43:73:47:89:0a:e1:3e:16.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '135.240.146.101' (RSA) to the list of known hosts.
TiMOS-C-11.0.R7 cpm/hops ALCATEL SR 7750 Copyright (c) 2000-2014 Alcatel-Lucent.
All rights reserved. All use subject to applicable license agreements.
Built on Tue Jan 14 14:19:43 PST 2014 by builder in /rel11.0/b1/R7/panos/main
admin@135.240.146.101's password:
A:NS101461484#
A:NS101461484# show bof
我想将其中的登录信息删除,即:
从每一个出现在行首的"spawn"开始到第一个出现在行尾的"password:"中间的内容全部删除。
希望处理后的文本变为:

A:NS101461484#
A:NS101461484# show time
Sun Nov 27 16:38:01 UTC 2016
A:NS101461484#
A:NS101461484#
A:NS101461484# show version
TiMOS-C-11.0.R7 cpm/hops ALCATEL SR 7750 Copyright (c) 2000-2014 Alcatel-Lucent.
All rights reserved. All use subject to applicable license agreements.
Built on Tue Jan 14 14:19:43 PST 2014 by builder in /rel11.0/b1/R7/panos/main
A:NS101461484#
A:NS101461484#
A:NS101461484# show bof

谢谢大家!


作者: moperyblue    时间: 2016-11-27 17:59

  1. sed '/^spawn /,/ password:/d'
复制代码

作者: bikkuri    时间: 2016-11-27 18:04
回复 2# moperyblue

谢谢!




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2