本文介绍了我如何组合这些线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何组合这些行(注意:这只是一个更大的文件的摘录):
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
,使其类似于:
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一线:
sed 'N;s/\n/ | /;s/\r//g' file.txt
这篇关于我如何组合这些线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!