首页 > 解决方案 > 在linux中水平排序

问题描述

我有一个像下面的文件有多个行和列,

a fn1.1 fn1.2 fn1.10 fn1.11

我想在文件中从第二个开始的列中进行字典排序。因此,每一行的输出应该是,

a fn1.1 fn1.10 fn1.11 fn1.2 

我使用过,LC_ALL=C sort /path_to_file/file但它没有提供所需的输出。例如,对于多行,

input
a fn1.1 fn1.2 fn1.10 fn1.11
b fn1.2 fn1.3 fn1.10 fn1.11
a fn1.10 fn1.20 fn1.13 fn1.12

desired output
a fn1.1 fn1.10 fn1.11 fn1.2
b fn1.10 fn1.11 fn1.2 fn1.3
a fn1.10 fn1.12 fn1.13 fn1.20

getting output
a fn1.1 fn1.2 fn1.10 fn1.11
a fn1.10 fn1.20 fn1.13 fn1.12
b fn1.2 fn1.2 fn1.10 fn1.11

请提出一些解决方案。

标签: linuxsortinglexicographic

解决方案


推荐阅读