-3

I have a text file with the following format. Is there a way to sort the data based on date/time and write it to another file. I know a way using python, but intend to use bash only for this.

15:19 09/01/21 string1
2:19 09/01/21 string2
1:19 09/01/21 string3
oguz ismail
  • 1
  • 16
  • 47
  • 69
SEU
  • 1,304
  • 4
  • 15
  • 36

1 Answers1

0

You can try a Schwartzian transform like so:

cut -d ' ' -f 1,2 file |
date -f - +%s          |
paste - file           |
sort -n                |
cut -f 2-
oguz ismail
  • 1
  • 16
  • 47
  • 69