我怎样才能结合这些线 [英] how can I combine these lines

查看:18
本文介绍了我怎样才能结合这些线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何合并这些行(注意:这只是一个更大文件的摘录):

How can I combine these lines (NOTE: this is just an excerpt from a much larger file):

interface GigabitEthernet0/0
 no ip proxy-arp
interface GigabitEthernet0/0.202
 no ip proxy-arp
interface GigabitEthernet0/0.358
 no ip proxy-arp
interface FastEthernet0/0/1.26
 no ip proxy-arp
interface GigabitEthernet0/0
 no ip proxy-arp
interface GigabitEthernet0/0.202
 no ip proxy-arp
interface GigabitEthernet0/0.358
 no ip proxy-arp
interface FastEthernet0/0/1.26
 no ip proxy-arp
interface Loopback0
 no ip proxy-arp
interface Loopback1
 no ip proxy-arp
interface Loopback26
 no ip proxy-arp
interface GigabitEthernet0/0/0
 no ip proxy-arp

所以它们看起来像这样:

so that they resemble this:

interface GigabitEthernet0/0 | no ip proxy-arp
interface GigabitEthernet0/0.202 | no ip proxy-arp
interface GigabitEthernet0/0.358 | no ip proxy-arp
interface FastEthernet0/0/1.26 | no ip proxy-arp
interface GigabitEthernet0/0 | no ip proxy-arp
interface GigabitEthernet0/0.202 | no ip proxy-arp
interface GigabitEthernet0/0.358 | no ip proxy-arp
interface FastEthernet0/0/1.26 | no ip proxy-arp
interface Loopback0 | no ip proxy-arp
interface Loopback1 | no ip proxy-arp
interface Loopback26 | no ip proxy-arp
interface GigabitEthernet0/0/0 | no ip proxy-arp

我尝试了一些在网上找到的不同解决方案,但它们似乎都不适用于我的情况

I've tried a few different solutions that I have found online, but none of them seem to work correctly for my situation

推荐答案

试试这个 sed one-liner:

Try this sed one-liner:

sed 'N;s/
/ | /;s/
//g' file.txt

这篇关于我怎样才能结合这些线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆