吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 892|回复: 3
收起左侧

[求助] 文本内容排列

[复制链接]
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

 楼主| 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 编辑

挺好,不错
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-11-25 05:51

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表