本帖最后由 yujw668 于 2018-8-27 18:32 编辑
A文本内容如下:
192.168.1.1 2111.1331.1111.2226
192.168.1.3 2111.1111.1111.2228
192.168.1.5 1111.1121.1111.2216
192.168.1.6 7113.1661.1111.2224
192.168.1.9 213.1361.1111.2222
192.168.1.12 1213.1664.1111.1221
192.168.1.23 9613.1651.1111.2321
192.168.1.90 7813.1641.1111.2290
192.168.3.5 2913.1664.1111.2215
192.168.3.23 9633.1651.1111.2223
192.168.3.9 7819.1641.1111.2239
B文本内容如下:
192.168.1.1 1111.1331.1111.2226 mac 机器1
192.168.1.3 1111.1111.1111.2228 windows 机器7
192.168.1.5 1111.1121.1111.2216 linux 机器1
192.168.1.6 7113.1661.1111.2224 linux 机器4
192.168.1.9 513.1361.1111.2222 windows 机器3
192.168.1.12 1213.1664.1111.1221 windows 机器1
192.168.1.23 9613.1651.1111.2321 mac 机器2
192.168.1.90 7813.1641.1111.2290 机器1
192.168.3.23 9633.1651.1111.2223 机器9
192.168.3.9 7819.1641.1111.2239 lixux 机器0
生成的C文本如下:
192.168.1.1 2111.1331.1111.2226 mac=机器1
192.168.1.3 2111.1111.1111.2228 windows=机器7
192.168.1.5 1111.1121.1111.2216 linux=机器1
192.168.1.6 7113.1661.1111.2224 linux=机器4
192.168.1.9 213.1361.1111.2222 windows=机器3
192.168.1.12 1213.1664.1111.1221 windows=机器1
192.168.1.23 9613.1651.1111.2321 mac=机器2
192.168.1.90 7813.1641.1111.2290 机器1=
192.168.3.5 2913.1664.1111.2215
192.168.3.23 9633.1651.1111.2223 机器9=
192.168.3.9 7819.1641.1111.2239 lixux=机器0
不知道为什么多列枚举的时候会多出=号,该怎么处理呢?
代码如下- @echo off
- setlocal ENABLEDELAYEDEXPANSION
- for /f "tokens=1,3,4" %%a in (B.txt) do set %%a=%%b=%%c
- (for /f "tokens=1,2" %%a in (A.txt) do echo %%a %%b !%%a! !%%b!)>c.txt
复制代码 描述,列出A文本的1,2列,并添加B文本的3,4列 合并到C文本导出。 |