我有这样的档案:
TAB | STAT | RECORDS
------------------------
TAB1
DUPKEY
26
TAB1
DUPKEY
26
TAB1
DUPKEY
26
TAB1
DUPKEY
26
TAB1
DUPKEY
26
TAB1
DUPKEY
26
TAB1
DUPKEY
26
TAB1
DUPKEY
26
正如您所看到的,有多条线,它们是相同的。我需要的是创建一个名为report.dat的文件,输出将是
TAB | STAT | RECORDS
------------------------
TAB1 DUPKEY 26
我该怎么做?
答案 0 :(得分:0)
# print the first 2 lines
sed 2q file
# skip the first 2 lines, join 3 lines into 1, then get unique lines
sed 1,2d file | paste - - - | sort -u
TAB | STAT | RECORDS
------------------------
TAB1 DUPKEY 26
paste
默认情况下与制表符加入