本帖最后由 思想之翼 于 2024-12-1 18:03 编辑
回复 9# hfxiang
感谢关注!不知道问题出在哪?
运行下列代码,结果正确:- gawk -v"N=2,4,13,40,50-70,74,78,94-96,98,100" -v"RS=\r?\n| " -v"ORS= " "{++d[$0]}END{split(N,M,/[^0-9]+/,s);A[M[1]];for(j in s){if(s[j]==\"-\"){for(i=M[j];i<=M[j+1];i++)A[i]}else{A[M[j+1]]}};for(j in A){for(i in d)if(d[i]==j)print i}}" D:\JZ1\1.txt > D:\JZ2\1.txt]
复制代码 运行下列代码,不输出文本:- @echo off
- setlocal enabledelayedexpansion
- for /l %%d in (1,1,2) do (
- set o=%%d
- gawk -v"N=2,4,13,40,50-70,74,78,94-96,98,100" -v"RS=\r?\n| " -v"ORS= " "{++d[$0]}END{split(N,M,/[^0-9]+/,s);A[M[1]];for(j in s){if(s[j]==\"-\"){for(i=M[j];i<=M[j+1];i++)A[i]}else{A[M[j+1]]}};for(j in A){for(i in d)if(d[i]==j)print i}}" D:\JZ1\!o!.txt > D:\JZ2\!o!.txt
- )
- endlocal
- exit
复制代码 测试文本 1.txt 2.txt 记录数值相同,格式如下:
G B B
B C C C
J A A A A
J
E
E D
0000 0000 0000 0000 0000
0000 0000 0000 0000 0000
0000 0000 0000 |