If I have a list of file names (absolute path), how do I determine which one is last modified in command line?
Thanks!
Try this:
find . -type f | xargs stat --format '%Y :%y %n' | sort -nr | cut -d' ' -f5- | head
find . -type f # find all FILES only in the current directory
xargs stat --format '%Y :%y %n' # perform a stat on the file
# ( xargs helps in 'stringing together commands')
# %Y time of last modification since Epoch
# %y time of last modification human readable
# %n file name
sort -nr # -n, sort according to numerical value, -r reverse
cut -d' ' -f5 # cut output by ' ' (space) and print column five
head # show the first 10 lines
For OS X's stat:
Use
-c'%Y %n'
with GNU stat.Different ways to find files sorted by modification date: