回复 1# 思想之翼
【问题1】- @echo off
- gawk -F"=" "NR==FNR{A[$1]=$2;next}{c=split($0,B,/[ \t]+/,m);for(i=1;i<=c;i++)printf(\"%%s%%s\",A[B[i]],m[i]);print A[B[i+1]]}" A.txt B.txt >C.txt
复制代码 【问题2】- @echo off
- gawk -F"=" -v"tab=\t" "BEGIN{A[\"\t\"]=\"\t\"}NR==FNR{A[$1]=$2;next}{c=split($0,B,//);printf A[B[1]];t1=A[B[i]];for(i=2;i<=c;i++){((A[B[i]]~tab)||(t1~tab))?t=1:t=0;printf(t?\"%%s\":\" %%s\",A[B[i]]);t1=A[B[i]]};print \"\"}" A.txt B.txt >C.txt
复制代码
|