Mike Q
Mike Q

Reputation: 7327

Sort by just Month name and day. Bash

Hello Trying to sort this list by Month and day. Can not get it staight. Any pointers ?

List example:

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)

Upvotes: 2

Views: 6284

Answers (2)

Quatro por Quatro
Quatro por Quatro

Reputation: 51

when working on foreign computers we must set the language before sorting this kind of data:

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

Upvotes: 0

chepner
chepner

Reputation: 531165

If you version of sort supports it:

sort -k1,1M -k2,2n

Upvotes: 14

Related Questions