Find the files that have been changed in the last 24 hours
To find all files modified in the last 24 hours (last full day) in a particular specific directory and its sub-directories:
find /directory_path -mtime -1 -ls
The -
before 1
is important – it means anything changed one day or less ago. A +
before 1
would instead mean anything changed at least one day ago, while having nothing before the 1
would have meant it was changed exacted one day ago, no more, no less.
find . -mtime 0 -printf '%T+\t%s\t%p\n' 2>/dev/null | sort -r | more
On GNU-compatible systems (i.e. Linux):
find . -mtime 0 -printf '%T+\t%s\t%p\n' 2>/dev/null | sort -r | more
This will list files and directories that have been modified in the last 24 hours (-mtime 0
). It will list them with the last modified time in a format that is both sortable and human-readable (%T+
), followed by the file size (%s
), followed by the full filename (%p
), each separated by tabs (\t
).
2>/dev/null
throws away any stderr output, so that error messages don’t muddy the waters; sort -r
sorts the results by most recently modified first; and | more
lists one page of results at a time.
Add a -name option to find specific file types, for instance:
find /var -name "*.php" -mtime -1 -ls
Leave a Comment