I am writing a bash script to look for a file which's file name is most recently and file name like:...Wed_Dec_30_16:47:41_PHT_2015.zipWed_Dec_30_16:00:41_PHT_2015.zipWed_Dec_30_16:00:41_PHT_2015.zipThu_Dec_31_16:49:14_PHT_2015.zip...I'm search all .zip file use find command and i thought maybe i need a array like:readarray -t lines <<< $(find . -type f -name '*.zip' -exec basename {} \;|tr -d '[.zip]'|tr '_' ' ')len=${#lines[@]}for ((i=0;i<len;i++)); do    echo ${lines[$i]}doneAnd, i got all of file name (with date time) like this in terminal. it looks completly:Wed Dec 30 16:47:41 PHT 2015Wed Dec 30 16:00:35 PHT 2015Thu Dec 31 12:14:13 PHT 2015Thu Dec 31 12:19:34 PHT 2015Wed Dec 30 16:49:14 PHT 2015Thu Dec 31 13:01:11 PHT 2015Mon Dec 28 12:35:44 PHT 2015...But, i'm not sure how can i compare those many string as i use date.And absolutely I'm not sure it's a really and complate way to revert the file whichs string like Wed Dec 30 16:49:14 PHT 2015 to Wed_Dec_30_16:49:14_PHT_2015.zipThanks for help.Edit:I fix my script, and i comvert 'string' to 'date' which is seconds level:declare -a my_arraylen=${#lines[@]}for ((i=0;i<$len;i++));do    my_array[$i]=`date -d ${lines[$i]} +%s`doneand choose the max one:max=${my_array[0]}for((i=0;i<$len;i++));do    if [ ${my_array[$i]} -gt $max ];then max=${my_array[$i]};fidoneecho $maxterminal:14514652611451462435145153525314515355741451465354145153807114512773441451538071 <== max oneSo, should i revert it like: Wed_Dec_30_16:00:41_PHT_2015.zip?Does anyone have a simple way?
search the most latest's file name
files;find;date;string
With gnu sort having input.txt as input (explain):cat input.txt | sort -t _ -k6n,6.4 -k2M -k3n -k4.1n,4.2 -k4.4n,4.5 -k4.7n,4.8Add --debug flag to see fields used for sorting. Useful when you have to tweak substrings:Wed_Dec_30_16:00:41_PHT_2015.zip                        ____    ___        __           __              __                 __