Find latest files in all subdirectories per directory

From Wiki
Jump to navigation Jump to search

Create a file <syntaxhighlight lang="bash">

ls -lrt "$1" | tail -n1

</syntaxhighlight> Make it executable

chmod +x ./

Then execute the following command:

find . -mindepth 1 -type d -printf "%T+ %p/" -exec ./ {} \;


2015-02-07+04:01:53.0000000000 ./$RCE/SLES11-SP2-Updates/sle-11-i586/repodata/repomd.xml.key
2015-02-07+04:02:09.0000000000 ./$RCE/SLES11-SP2-Updates/sle-11-i586/repodata
2015-02-07+04:07:41.0000000000 ./$RCE/SLES11-SP3-Pool/sle-11-i586/.repodata/repomd.xml.key
2015-02-07+04:07:41.0000000000 ./$RCE/SLES11-SP3-Pool/sle-11-i586/rpm

When outputted to a file (list.txt) then you could follow up with:

cat list.txt | grep -v repomd | grep rpm | sort