Can anyone advise how do I use ls to do a selective amd sorted listing of file that I want to have as below?
Am looking for files that are named as log_<nnnn>.txt, where <nnnn> are numeric, i.e. I want to have a listing sorted from the newest to the oldest of files that starts with log_ and with a .txt extension and the characters in between these two can only be numeric, example log_1.txt, log_234.txt, log_222.txt etc.
I want to exclude files like log_9ab.txt, log_a9b.txt., log_99a.txt
I thought I can get away with doing
ls -1tr log_[0-9][0-9]*.xml
but unfortunately the * list also files like log_99a.txt.
I want to be able to only list files where the characters in between log_ and .txt are numeric, unfortunately, sometimes, there can be 2, 3 or 5 numeric characters.
Any advise will be much appreciated. Thanks in advance.