按月份名称和日期排序。巴什

时间:2012-08-28 15:05:12

标签: bash sorting

您好试图按月和日排序此列表。不能得到它的直言不讳。有什么指针吗?

列表示例:

Jul 23 Drive :NTFS (Windows 31.6 GB/29.4 GiB) Details : Mounted /dev/sdc1 (Read-Write, label "FreeAgent GoFlex Drive", NTFS 3.1)
Jul 30 Drive :NTFS (Windows 31.6 GB/29.4 GiB) Details : Mounted /dev/sdb1 (Read-Write, label "HP USB FD", NTFS 3.1)
Aug 2 Drive :NTFS (Windows 31.6 GB/29.4 GiB) Details : Mounted /dev/sdb1 (Read-Write, label "WINPART", NTFS 3.1)
Jul 24 Drive :EXT (Linux) Details : EXT3-fs (sdc1)
Jul 25 Drive :EXT (Linux) Details : EXT3-fs (sdb1)
Jul 27 Drive :EXT (Linux) Details : EXT4-fs (sdb2)
Aug 2 Drive :EXT (Linux) Details : EXT3-fs (sdb1)
Aug 2 Drive :EXT (Linux) Details : EXT4-fs (sdb1)

2 个答案:

答案 0 :(得分:9)

如果您sort的版本支持它:

sort -k1,1M -k2,2n

答案 1 :(得分:0)

在外国计算机上工作时,我们必须在排序此类数据之前设置语言:

LC_ALL=C sort -k1,1M -k2,2n file.txt