October 27, 2016

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 :


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.


If you enjoyed this website, consider buying me a Dr. Pepper

Buy me a Dr PepperBuy me a Dr Pepper