Unix排序不是从第一个字符开始

时间:2018-08-23 19:14:48

标签: bash sorting unix

我有以下数据

% [START_TIME - END_TIME] TURN_NAME EMOTION [V, A, D]
[6.2901 - 8.2357]   Ses01F_impro01_F000 neu [2.5000, 2.5000, 2.5000]
[10.0100 - 11.3925] Ses01F_impro01_F001 neu [2.5000, 2.5000, 2.5000]
[14.8872 - 18.0175] Ses01F_impro01_F002 neu [2.5000, 2.5000, 2.5000]
[97.8900 - 102.9600]    Ses01F_impro01_F014 neu [2.5000, 3.5000, 3.5000]
[103.9700 - 106.7100]   Ses01F_impro01_F015 fru [2.0000, 3.5000, 3.0000]
[7.5712 - 10.4750]  Ses01F_impro01_M000 fru [2.5000, 2.0000, 2.5000]
[10.9266 - 14.6649] Ses01F_impro01_M001 fru [2.5000, 2.0000, 2.5000]
[16.8352 - 19.7175] Ses01F_impro01_M002 fru [2.0000, 3.5000, 3.5000]
[23.4700 - 28.0300] Ses01F_impro01_M003 fru [2.5000, 3.5000, 3.5000]
[101.8400 - 107.8700]   Ses01F_impro01_M013 ang [2.0000, 4.5000, 4.5000]

我期望在sort命令之后得到以下结果,

 % [START_TIME - END_TIME] TURN_NAME EMOTION [V, A, D]
[6.2901 - 8.2357]   Ses01F_impro01_F000 neu [2.5000, 2.5000, 2.5000]
[7.5712 - 10.4750]  Ses01F_impro01_M000 fru [2.5000, 2.0000, 2.5000]
[10.0100 - 11.3925] Ses01F_impro01_F001 neu [2.5000, 2.5000, 2.5000]
[10.9266 - 14.6649] Ses01F_impro01_M001 fru [2.5000, 2.0000, 2.5000]
[14.8872 - 18.0175] Ses01F_impro01_F002 neu [2.5000, 2.5000, 2.5000]
[16.8352 - 19.7175] Ses01F_impro01_M002 fru [2.0000, 3.5000, 3.5000]
[23.4700 - 28.0300] Ses01F_impro01_M003 fru [2.5000, 3.5000, 3.5000]
[97.8900 - 102.9600]    Ses01F_impro01_F014 neu [2.5000, 3.5000, 3.5000]
[101.8400 - 107.8700]   Ses01F_impro01_M013 ang [2.0000, 4.5000, 4.5000]
[103.9700 - 106.7100]   Ses01F_impro01_F015 fru [2.0000, 3.5000, 3.0000]

我使用以下sort命令从第二个字符开始排序

 sort -k1.2 filename 

但是它给出了[10.0100....]的第一行。因此,sort命令将根据最左边的十进制数字(START_TIME)进行排序,同时将标题保留在顶部。这里的任何有经验的sort用户都可以帮助...?

1 个答案:

答案 0 :(得分:1)

您需要使用select duration * interval '1 microsecond' 选项指定要数字排序:

-g