Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个结构像这样的文件(太大)
A B C,D,E,F
第三列包含用逗号分隔的 4 个值(但可以是变量)。我想将该文件转换为
A B C A B D A B E A B F
基本上复制前两个并将第二个分成几行。
关于如何做到这一点的任何想法awk?
awk
$ awk '{n=split($3,a,/,/);for(i=1;i<=n;i++)print $1,$2,a[i]}' file A B C A B D A B E A B F