Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/sorting/2.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 排序选项卡分隔的文件,带标题_Unix_Sorting - Fatal编程技术网

Unix 排序选项卡分隔的文件,带标题

Unix 排序选项卡分隔的文件,带标题,unix,sorting,Unix,Sorting,我有一个文件的头是用@blabla指定的-不同的文件有不同数量的头行,但它们都用@sign指定头行 即 在标题之后,文件以制表符分隔 任何人都知道在linux中对该文件进行排序的快速/简单方法(可能使用sort命令) 我想按第1列(然后是第4列)对其进行排序,但在排序后的版本中保留标题作为标题 谢谢你的帮助 谢谢 您可以删除标题、排序,然后添加标题 $ grep '^@' foo > foo.sorted; grep -v '^@' foo | sort --key=2,4 >>

我有一个文件的头是用@blabla指定的-不同的文件有不同数量的头行,但它们都用@sign指定头行

在标题之后,文件以制表符分隔

任何人都知道在linux中对该文件进行排序的快速/简单方法(可能使用sort命令)

我想按第1列(然后是第4列)对其进行排序,但在排序后的版本中保留标题作为标题

谢谢你的帮助


谢谢

您可以删除标题、排序,然后添加标题

$ grep '^@' foo > foo.sorted; grep -v '^@' foo | sort --key=2,4 >> foo.sorted
$ cat foo.sorted 
@HI this is header line 1
@Bye this is header line 2
9 134 hi 190 hl df de
9 179 hi 110 hl df de
2 190 hi 1310 hl df de
2 210 hi 1300 hl df de
awk'NR2{print |“sort-t\”\“-k1,1n-k4,4n”}'foo.txt
$ grep '^@' foo > foo.sorted; grep -v '^@' foo | sort --key=2,4 >> foo.sorted
$ cat foo.sorted 
@HI this is header line 1
@Bye this is header line 2
9 134 hi 190 hl df de
9 179 hi 110 hl df de
2 190 hi 1310 hl df de
2 210 hi 1300 hl df de
awk 'NR<=2{print}NR>2{print|"sort -t\"    \" -k1,1n -k4,4n"}' foo.txt