Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在unix shell中显示一行并对文件进行排序?_Unix_Sorting_Row_Ksh - Fatal编程技术网

如何在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