Sort on part of string using ls & sort
Posted on October 27, 2016 • 1 minutes • 59 words • Suggest Changes
Sometimes sorting some files seems easy, but its not. For example this part :
(random_string)_(numeric_id)_(allot_of_digits)-(random_string)
Of course I would like to sort on numeric_id, and not on the random string; This is where command guru’s are master, I’m but a humble user, so I’d like to share my hacky solution !
ls -l | sort -t_ -k2
bam, sorted.