Coder Perfect

Locate any files that have been modified in the recent 24 hours.


On my Ubuntu machine, for example, a MySQL server is running. Some information has changed in the last 24 hours.

What (Linux) scripts are capable of locating files that have been modified in the recent 24 hours?

Please mention the file names, file sizes, and when they were last edited.

Asked by JackWM

Solution #1

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

It should suit your preferences.

The – before 1 is significant since it denotes any changes that occurred one day or fewer ago. Instead, a + before 1 would suggest anything changed at least one day ago, whereas nothing before 1 would mean it was changed exactly one day ago, no more, no less.

Answered by Xavjer

Solution #2

Another option, which is more humane:

find /<directory> -newermt "-24 hours" -ls


find /<directory> -newermt "1 day ago" -ls


find /<directory> -newermt "yesterday" -ls

Answered by Maxim Egorushkin

Solution #3

That is something you can accomplish using

find . -mtime 0

From man find:

Answered by Michael

Solution #4

On GNU-compatible (i.e. Linux) systems:

find . -mtime 0 -printf '%T+\t%s\t%p\n' 2>/dev/null | sort -r | more

This command displays a list of files and folders that have been modified in the previous 24 hours (-mtime 0). It will list them in a sortable and human-readable style, starting with the latest modified time (percent T+), then the file size (percent s), and finally the entire filename (percent p), all separated by tabs (\t).

2>/dev/null discards any stderr output to avoid muddying the waters with error messages; | more lists one page of results at a time, and sort -r sorts the results by most recently modified first.

Answered by Stephen G Tuggy

Solution #5

Add a -name option to identify specified file types for future visitors (including myself), for example: find /var -name “*.php” -ls -mtime -1

Answered by resedasue

Post is based on