I have found many answers to sort the files of directory and even to save them in an array.
Directory listing in array
My particular problem needs to sort files with a specific extension (say
*.sh) based on their modification date/time, and save all these sorted files in array to be used later for editing or deleting file.
For example, after I have the sorted files in the array I could execute remove the most recent file by the following command.