使用SED在文件

时间:2017-03-09 04:21:25

标签: regex sed

我在文本文件中转储了所有灰熊步骤主机。这是文件的样子:

(Table: network_objects) Name: Bad-Host_89.b.c.d (Table: network_objects) Name: Bad-Host_89.b.c.d (Table: network_objects) Name: Bad-Host_89.b.c.d (Table: network_objects) Name: Bad-Host_89.b.c.d (Table: network_objects) Name: Bad-Host_89.b.c.d (Table: network_objects) Name: Bad-Host_89.b.c.d (Table: network_objects) Name: Bad-Host_89.b.c.d (Table: network_objects) Name: Bad-Host_89.b.c.d (Table: network_objects) Name: Bad-Host_89.b.c.d (Table: network_objects) Name: Bad-Host_89..b.c.d (Table: network_objects) Name: Bad-Host_89.b.c.d (Table: network_objects) Name: Bad-Host_89.b.c.d (Table: network_objects) Name: Bad-Host_89.b.c.d (Table: network_objects) Name: Bad-Host_89.b.c.d

正如你所看到的,它是一个巨大的巨人。我想使用sed匹配(T并在匹配的字符串之前插入换行符。基本上我希望输出看起来像这样:

(Table: network_objects) Name: Bad-Host_89..b.c.d  
(Table: network_objects) Name: Bad-Host_89..b.c.d 
...

1 个答案:

答案 0 :(得分:0)

就像这样:

AMD$ sed 's/(T/\n&/g' File

(Table: network_objects) Name: Bad-Host_89.b.c.d
(Table: network_objects) Name: Bad-Host_89.b.c.d
(Table: network_objects) Name: Bad-Host_89..b.c.d
(Table: network_objects) Name: Bad-Host_89..b.c.d
(Table: network_objects) Name: Bad-Host_89..b.c.d
(Table: network_objects) Name: Bad-Host_89..b.c.d
(Table: network_objects) Name: Bad-Host_89..b.c.d
(Table: network_objects) Name: Bad-Host_89..b.c.d
(Table: network_objects) Name: Bad-Host_89..b.c.d
(Table: network_objects) Name: Bad-Host_89..b.c.d
(Table: network_objects) Name: Bad-Host_89..b.c.d
(Table: network_objects) Name: Bad-Host_89..b.c.d
(Table: network_objects) Name: Bad-Host_89..b.c.d
(Table: network_objects) Name: Bad-Host_89.b.c.d