首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > perl python >

Shell 用Sed和Awk 实现过滤文本中一段内容

2012-02-27 
Shell 求助用Sed和Awk 实现过滤文本中一段内容文本内容test.catStopping GUID serverRemoving old wwn_db

Shell 求助用Sed和Awk 实现过滤文本中一段内容
文本内容test.cat
Stopping GUID server

Removing old wwn_db database.

Create new wwn_db database for restore.

Created wwn_db database.
Created wwn range table.
Created wwn addr table.
Created wwn db version table.

Restoring wwn_db from: /var/opt/guid/backup/wwn_db/2011.11.30.01.17.44_wwn_db_backup

Restore of wwn_db sucessful.

Starting GUID server

将红色部分全部过滤去掉。
*注:红色部门路径文件名“2011.11.30.01.17.44_wwn_db_backup”内容不固定会有变化。
如:"/var/opt/guid/backup/wwn_db/2011.11.29.01.13.28_wwn_db_backup"
过滤后形成如下内容:
Stopping GUID server

Removing old wwn_db database.

Create new wwn_db database for restore.

Created wwn_db database.
Created wwn range table.
Created wwn addr table.
Created wwn db version table.

Restoring wwn_db from: 

Restore of wwn_db sucessful.



Starting GUID server

[解决办法]
下面的sed命令会把以"Restoring www_db from:"开头的行换成"Restoring www_db from:".

sed "s/^Restoring wwn_db from:.*/Restoring www_db from:/"

热点排行