- 论坛徽章:
- 25
|
回复 1# xxinganling
回复 2# a5love3n
这样定义变量a,逗号前面就没有空格了。
- cat 1
- #
- interface LoopBack600
- description to-lb600
- ip address 192.168.2.45 255.255.255.255
- #
- interface LoopBack800
- description to-lb800
- ip address 172.18.32.96 255.255.255.255
- #
- #
- interface Vlan-interface634
- description TO-unit34
- ip address 192.168.1.66 255.255.255.252
- ospf cost 200
- ospf network-type p2p
- ospf bfd enable
- #
- #
- interface FastEthernet 0/30
- no switchport
- ip ospf network point-to-point
- ip ospf authentication message-digest
- ip ospf message-digest-key 1 md5 7 141a46076330240c541752
- ip ospf cost 50
- no ip proxy-arp
- ip address 192.168.6.32 255.255.255.252
- description Connect_to_unit30
- #
- awk '/^interface/{if(a&&b&&c){print a","b","c};a=b=c="";a=gensub($1" ","","1",$0)}/^ip address/{b=$3}/^description/{c=$2}END{if(a&&b&&c){print a","b","c}}' 1
- LoopBack600,192.168.2.45,to-lb600
- LoopBack800,172.18.32.96,to-lb800
- Vlan-interface634,192.168.1.66,TO-unit34
- FastEthernet 0/30,192.168.6.32,Connect_to_unit30
复制代码 |
|