Try:
ls -rt *.txt | xargs grep -l <pattern>
We first use ls to list *.txt files and sort them by modification time (newest last), then for each entry run them through grep so we only print out files that contain the pattern.
Try:
ls -rt *.txt | xargs grep -l <pattern>
We first use ls to list *.txt files and sort them by modification time (newest last), then for each entry run them through grep so we only print out files that contain the pattern.