I am currently working on a project where I need to find the oldest file from a base name within the directory.
For example the base name of the file may be mylog but it will need to look at all files like mylog_060620121421.txt. From all the files that are mylog_ I need to find out which file is the oldeest, i.e. created first but I can’t find how to do this.
I’ve seen the scandir command to list the file names but I can’t see how it can be used to find the oldest date of the file.
On linux just type in the dir:
This gives a list, beginning with the oldest file. If you want the name directly you can get it with: