按匹配字段排序

时间:2016-06-15 10:55:22

标签: bash sorting unix

假设我有一个文件F:

hi xb 9 test
hi xc 8 test
hi xa 7 test

我需要对这个文件的行进行排序。但我有两种方法可以对它们进行排序。

方法1:按列排序。 我如何按行排序,比如第2列(xb,xc,xa)或第3列(8,9,7)?

如果按第2列排序,预期输出:

hi xa 7 test
hi xb 9 test
hi xc 8 test

方法2:按第3列上的数字排序。 我需要在第3列捕获数字的正则表达式是什么?

预期产出:

hi xa 7 test
hi xc 8 test
hi xb 9 test

0 个答案:

没有答案
相关问题