回复 1# 思想之翼
以下是gawk方案
注意:"D:\DATA2\A.txt"需保存为ANSI编码格式,对应的文件夹(如“D:\DATA2\01\”等)需提前建立
1.命令行方式(单百分号%)- gawk -v"FS=" -v"pt=D:/DATA2/" "NR%2==1{++n;for(i=1;i<=NF;i++){close(Fn[i]);Fn[i]=sprintf(\"%s%02d/A_%04d.txt\",pt,n,i)}}{for(i=1;i<=NF;i++){print $i>Fn[i]}}" "D:\DATA2\A.txt"
复制代码 2.脚本方式(双百分号%)- gawk -v"FS=" -v"pt=D:/DATA2/" "NR%%2==1{++n;for(i=1;i<=NF;i++){close(Fn[i]);Fn[i]=sprintf(\"%%s%%02d/A_%%04d.txt\",pt,n,i)}}{for(i=1;i<=NF;i++){print $i>Fn[i]}}" "D:\DATA2\A.txt"
复制代码
|