How can I sort the below files based on the date and time inside the folder and delete the older ones and keep the most recent ones in Linux?
I just want to keep the latest one regardless of the actual date. It does not matter if the most recent file is even a year old, I just want to keep that.
aa_zz_yuyubc_207_dc_ghgh.brr.01_30_2019 3_15_04 am.csv aa_zz_chuucd.brr.04_30_2020 7_15_12 pm.csv aa_zz_ddetr_354_m.brr.5_25_2021 03_28_00 am.csv aa_zz_xyf.brr.6_05_2021 5_20_55 PM.csv
Expected result: only
aa_zz_xyf.brr.6_05_2021 5_20_55 PM.csv remains:
Dates are in
<month>_<day>_<year> <hour>_<minute>_<second> am/pm (12 hour format).