Latest list of files of each type

find /tmp/testlog/kSR*"_"2018* -type f -printf '%T@ %p\n' | sort -n | tail -3 | cut -f2- -d" " 
/tmp/testlog/log/KSR04_2018-07-05.log
/tmp/testlog/log/KSR04_2018-07-06.log
/tmp/testlog/log/KSR01_2018-07-06.log

But, I would see the following output(latest files for each KSR tuype)

/tmp/testlog/log/KSR04_2018-07-06.log
 /tmp/testlog/log/KSR01_2018-07-06.log
tail -2

what happens if more than 2 files with latest dates and i need dynamic script

/tmp/testlog/log/KSR01_2018-07-05.log
/tmp/testlog/log/KSR01_2018-07-06.log
/tmp/testlog/log/KSR04_2018-07-06.log
/tmp/testlog/log/KSR03_2018-07-06.log

I'm very confused...

The command:

find /tmp/testlog/kSR*"_"2018* -type f -printf '%T@ %p\n' | sort -n | tail -3 | cut -f2- -d" "

is never going to produce the output:

/tmp/testlog/log/KSR04_2018-07-05.log
/tmp/testlog/log/KSR04_2018-07-06.log
/tmp/testlog/log/KSR01_2018-07-06.log

because testlog/kSR* is never going to match testlog/log/KSR .

Are you trying to print all filenames with the latest date in the filename:

/tmp/testlog/log/KSR01_2018-07-06.log
/tmp/testlog/log/KSR04_2018-07-06.log
/tmp/testlog/log/KSR03_2018-07-06.log

???

Are you trying to print the most recently modified filenames with different numbers between KSR and _ (which in this case would be the same files)???

Are all of the files you're interested in in a single directory (as shown in your examples)? Or, are they spread out in various directories under the directory /tmp/testlog/log ?

Is the first part of the filenames you want to match kSR or KSR ?

What operating system are you using?

What shell are you using?

P.S. Is it OK if the most recent file is printed first instead of last?

If you're trying to get the most recent names with different numbers before the underscore, does the order of the output lines matter as long as the filenames you want are all printed?