How about another date-based trivia question? This time you have a text file where the first field is a date in the American style "MM/DD/YYYY" format (let me apologize to the rest of the world for what can only be described as a terrible mistake). How do you sort the lines in the file by date without changing the text on each line?

#Linux #DFIR #CommandLine #Trivia

Yesterday's Linux DFIR command line trivia asked how to sort lines of a text file on an initial date field in the American date style, "MM/DD/YYYY", without rewriting the line.

Shout out to @mish for checking in with a solution to leverage the ability to sort on fields:

sort -t/ -n -k3,3 -k1,1 -k2,2 input.txt

"-t/" means break up the fields on "/" characters rather than spaces, and "-n" means we're going to sort numerically rather than alphabetically. "-k" lets us specify the "key fields" we want to sort on: year first, then month, then day.

Yay for "sort"!

#Linux #DFIR #CommandLine #Trivia

@hal_pomeranz @mish I’m so glad @johntimaeus told me about you and this daily trivia for Linux.