Sort grep results by last modified time of the files
From raju
sort grep results by last modified time of the files
To sort the output of "grep -l" by last modified time of the files
grep -l <pattern> * | xargs ls -1tr
or
grep -l <pattern> *.txt | xargs ls -ltr --time-style="+%Y%m%d_%H%M"
Sample usage:-
$git grep -l argparse | xargs ls -ltr --time-style="+%Y%m%d_%H%M" -rwxr-xr-x 1 raju 197121 4994 20171030_2323 debian_user/gather_system_info.py -rwxr-xr-x 1 raju 197121 979 20171030_2323 bin/list_dep.py -rwxr-xr-x 1 raju 197121 14329 20180129_2216 bin/grep_installed.py -rwxr-xr-x 1 raju 197121 7517 20180129_2216 bin/popsort.py -rwxr-xr-x 1 raju 197121 1552 20180827_2319 python3/make_bkup.py -rw-r--r-- 1 raju 197121 1085 20181103_0818 python3/disk_usage.py -rwxr-xr-x 1 raju 197121 940 20181103_0836 python3/why_package.py -rwxr-xr-x 1 raju 197121 4264 20181103_0837 python3/scottrade/scottrade.py -rw-r--r-- 1 raju 197121 1388 20181103_0838 python3/time_utils/time_calc.py -rwxr-xr-x 1 raju 197121 1228 20181103_0858 python3/rstrip.py -rwxr-xr-x 1 raju 197121 1232 20181103_0858 python3/stuff.py -rwxr-xr-x 1 raju 197121 2038 20181105_0059 python3/git_grep.py -rwxr-xr-x 1 raju 197121 1797 20181105_0101 python3/plot_utils/plot_by_index.py $git grep -l argparse | xargs ls -1rt debian_user/gather_system_info.py bin/list_dep.py bin/grep_installed.py bin/popsort.py python3/make_bkup.py python3/disk_usage.py python3/why_package.py python3/scottrade/scottrade.py python3/time_utils/time_calc.py python3/rstrip.py python3/stuff.py python3/git_grep.py python3/plot_utils/plot_by_index.py