Find latest files in all subdirectories per directory: Difference between revisions
Jump to navigation
Jump to search
(Created page with "Create a file latestfile.sh: #!/bin/bash ls -lrt "$1" | tail -n1 Make it executable chmod +x ./latestfile.sh Then execute the following command: find . -mindepth 1 -type d...") |
No edit summary |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
Create a file latestfile.sh: | Create a file latestfile.sh: | ||
<syntaxhighlight lang="bash"> | |||
#!/bin/bash | #!/bin/bash | ||
ls -lrt "$1" | tail -n1 | ls -lrt "$1" | tail -n1 | ||
</syntaxhighlight> | |||
Make it executable | Make it executable | ||
chmod +x ./latestfile.sh | chmod +x ./latestfile.sh | ||
Line 13: | Line 15: | ||
2015-02-07+04:07:41.0000000000 ./$RCE/SLES11-SP3-Pool/sle-11-i586/rpm | 2015-02-07+04:07:41.0000000000 ./$RCE/SLES11-SP3-Pool/sle-11-i586/rpm | ||
</pre> | </pre> | ||
When outputted to a file (list.txt) then you could follow up with: | |||
cat list.txt | grep -v repomd | grep rpm | sort |
Latest revision as of 16:38, 11 August 2015
Create a file latestfile.sh: <syntaxhighlight lang="bash">
#!/bin/bash ls -lrt "$1" | tail -n1
</syntaxhighlight> Make it executable
chmod +x ./latestfile.sh
Then execute the following command:
find . -mindepth 1 -type d -printf "%T+ %p/" -exec ./latestfile.sh {} \;
Output:
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