V
V
vlarkanov2019-03-07 12:53:37
linux
vlarkanov, 2019-03-07 12:53:37

Linux: how to count the total amount of files created between "date" and "date"?

Hello!
There is a directory with a bunch of subdirectories with files. It is necessary to calculate the total volume of all files created from "date" to "date". Tried like this:

find /mnt/directory/ -type f -mtime $(date +%s -d"Feb 1, 2019 00:00:01") -mtime $(date +%s -d"Feb 28, 2019 23:59:59") | du -sb --files0-from=-  | awk '{ total += $1} END { print total/1024/1024/1024 }'

but it seems that I screwed up with the condition - I got 0.
How to do it right?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
ky0, 2019-03-07
@ky0

Why do you have two times -mtime?

+n for greater than n,
-n for less than n,

V
vlarkanov, 2019-03-07
@vlarkanov

Understood. You need to specify these keys -newerct "1 Jan 2019" ! -newerct "1 Feb 2019"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question