我有如下输入,如果两行之间的第三列的值不同,则需要在行之间放置分隔符。
one two three four
five six three seven
eight nine ten elevel
alpha beta ten gama
tango charlie oscar bla
预期结果:
one two three four
five six three seven
=
eight nine ten elevel
alpha beta ten gama
=
tango charlie oscar bla
我认为这是行得通的,但行不通。
awk '{col3=$3;next} $3!=col3{$0="\n="$0;print $0}' input
最佳答案
$ awk '$3!=p && NR>1 { print "=" } { print; p=$3 }' file
one two three four
five six three seven
=
eight nine ten elevel
alpha beta ten gama
=
tango charlie oscar bla