如何在unix shell中显示一行并对文件进行排序?
我有这样的文件:如何在unix shell中显示一行并对文件进行排序?,unix,sorting,row,ksh,Unix,Sorting,Row,Ksh,我有这样的文件: 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 | RE
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
我怎么做
# 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
粘贴
默认情况下与制表符连接不起作用。本说明位于while循环内的if条件内。。可能有问题吗?
TAB | STAT | RECORDS
------------------------
TAB1 DUPKEY 26