qiulai 发表于 2022-11-12 22:56

文本内容排列

port.txt内容如下:
IF-MIB::ifDescr.10 = STRING: GigabitEthernet0/0/1
IF-MIB::ifDescr.11 = STRING: GigabitEthernet0/0/2
IF-MIB::ifDescr.12 = STRING: GigabitEthernet0/0/3
IF-MIB::ifDescr.13 = STRING: GigabitEthernet0/0/4
IF-MIB::ifDescr.14 = STRING: GigabitEthernet0/0/5
IF-MIB::ifDescr.15 = STRING: GigabitEthernet0/0/6
IF-MIB::ifDescr.16 = STRING: GigabitEthernet0/0/7
IF-MIB::ifDescr.17 = STRING: GigabitEthernet0/0/8
IF-MIB::ifDescr.18 = STRING: GigabitEthernet0/0/9
IF-MIB::ifDescr.19 = STRING: GigabitEthernet0/0/10
IF-MIB::ifDescr.20 = STRING: GigabitEthernet0/0/11
IF-MIB::ifDescr.21 = STRING: GigabitEthernet0/0/12
IF-MIB::ifDescr.22 = STRING: GigabitEthernet0/0/13
IF-MIB::ifDescr.23 = STRING: GigabitEthernet0/0/14
IF-MIB::ifDescr.24 = STRING: GigabitEthernet0/0/15
IF-MIB::ifDescr.25 = STRING: GigabitEthernet0/0/16
IF-MIB::ifDescr.26 = STRING: GigabitEthernet0/0/17
IF-MIB::ifDescr.27 = STRING: GigabitEthernet0/0/18
IF-MIB::ifDescr.28 = STRING: GigabitEthernet0/0/19
IF-MIB::ifDescr.29 = STRING: GigabitEthernet0/0/20
IF-MIB::ifDescr.30 = STRING: GigabitEthernet0/0/21
IF-MIB::ifDescr.31 = STRING: GigabitEthernet0/0/22
IF-MIB::ifDescr.32 = STRING: GigabitEthernet0/0/23
IF-MIB::ifDescr.33 = STRING: GigabitEthernet0/0/24
IF-MIB::ifOperStatus.10 = INTEGER: up(1)
IF-MIB::ifOperStatus.11 = INTEGER: up(1)
IF-MIB::ifOperStatus.12 = INTEGER: up(1)
IF-MIB::ifOperStatus.13 = INTEGER: down(2)
IF-MIB::ifOperStatus.14 = INTEGER: down(2)
IF-MIB::ifOperStatus.15 = INTEGER: down(2)
IF-MIB::ifOperStatus.16 = INTEGER: down(2)
IF-MIB::ifOperStatus.17 = INTEGER: down(2)
IF-MIB::ifOperStatus.18 = INTEGER: down(2)
IF-MIB::ifOperStatus.19 = INTEGER: down(2)
IF-MIB::ifOperStatus.20 = INTEGER: down(2)
IF-MIB::ifOperStatus.21 = INTEGER: down(2)
IF-MIB::ifOperStatus.22 = INTEGER: down(2)
IF-MIB::ifOperStatus.23 = INTEGER: down(2)
IF-MIB::ifOperStatus.24 = INTEGER: down(2)
IF-MIB::ifOperStatus.25 = INTEGER: down(2)
IF-MIB::ifOperStatus.26 = INTEGER: down(2)
IF-MIB::ifOperStatus.27 = INTEGER: down(2)
IF-MIB::ifOperStatus.28 = INTEGER: down(2)
IF-MIB::ifOperStatus.29 = INTEGER: down(2)
IF-MIB::ifOperStatus.30 = INTEGER: down(2)
IF-MIB::ifOperStatus.31 = INTEGER: down(2)
IF-MIB::ifOperStatus.32 = INTEGER: down(2)
IF-MIB::ifOperStatus.33 = INTEGER: up(1)

port.bat代码:
@echo off
setlocal enabledelayedexpansion
for /f "tokens=3 delims=:" %%a in ('type port.txt^|findstr /c:":"') do (
set str=%%a
set str=!str: =!
echo !str!
)
pause

怎么实现输出如下两列形式:
GigabitEthernet0/0/1 up(1)
GigabitEthernet0/0/2 up(1)
。。。。。。。。。。。
。。。。。。。。。。

luxingyu329 发表于 2022-11-13 08:53

本帖最后由 luxingyu329 于 2022-11-13 08:58 编辑

下载地址:https://luxingyu329.lanzoub.com/i39vC0ftbb6d

https://vkceyugu.cdn.bspapp.com/VKCEYUGU-6f00c918-7a62-47b5-8e8a-9578acfb171c/d9aa4111-d09d-4acf-8f38-5e7f6869f113.gif

qiulai 发表于 2022-11-13 09:24

本帖最后由 qiulai 于 2022-11-13 11:13 编辑

luxingyu329 发表于 2022-11-13 08:53
下载地址:https://luxingyu329.lanzoub.com/i39vC0ftbb6d
感谢老铁,我还想着分3列,4列
IF-MIB::ifDescr.10 = STRING: GigabitEthernet0/0/1
IF-MIB::ifDescr.11 = STRING: GigabitEthernet0/0/2
IF-MIB::ifDescr.12 = STRING: GigabitEthernet0/0/3
IF-MIB::ifDescr.13 = STRING: GigabitEthernet0/0/4
IF-MIB::ifOperStatus.10 = INTEGER: up(1)
IF-MIB::ifOperStatus.11 = INTEGER: up(1)
IF-MIB::ifOperStatus.12 = INTEGER: up(1)
IF-MIB::ifOperStatus.13 = INTEGER: down(2)
IF-MIB::ifPhysAddress.10 = STRING: 4c:1f:cc:98:7b:64
IF-MIB::ifPhysAddress.11 = STRING: 4c:1f:cc:98:7b:64
IF-MIB::ifPhysAddress.12 = STRING: 4c:1f:cc:98:7b:64
IF-MIB::ifPhysAddress.13 = STRING: 4c:1f:cc:98:7b:64
…………………………………………………………………………………………
…………………………………………………………………………………………
…………………………………………………………………………………………
排列如下:
GigabitEthernet0/0/1 4C-1F-CC-98-7B-64 up
GigabitEthernet0/0/2 4C-1F-CC-98-7B-64 up
GigabitEthernet0/0/3 4C-1F-CC-98-7B-64 up
GigabitEthernet0/0/4 4C-1F-CC-98-7B-64 down


luxingyu329 发表于 2022-11-13 09:40

本帖最后由 luxingyu329 于 2022-11-13 09:52 编辑

挺好,不错
页: [1]
查看完整版本: 文本内容排列