Is it possible to get the modification date and time of a folder?
I know you can use stat -f "%m" folder
, but it doesn't reflect sub-files/folders changes.
Things that doesn't work:
ls -l folder
- doesn't reflect changes inside the folderstat -f "%m" folder
- same as abovedate -r folder
- same againfind foo bar baz -printf
- the printf
option doesn't exist on my version of findVersions of things:
Solution:
find . -exec stat -f "%m" \{} \; | sort -n -r | head -1
Explanation:
find
command traverses the current directory (.
) and for each file encountered executes (-exec
) the command stat -f "%m"
. stat -f "%m"
prints the last modification unix timestamp of the file.sort -n -r
sorts the output of the find
command numerically (-n
) in reverse order (-r
). This will list the latest modification timestamp first.head -1
then extracts the first line of the output from sort
. This is the latest modification unix timestamp of all the files.You could try 'date -r folder' to give you a date last modified
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With