A
A
a000_000a2018-04-23 18:03:45
bash
a000_000a, 2018-04-23 18:03:45

How, using a bash script, to calculate the size of all files in a directory created in a certain year?

There is a directory /home/user/repo/
Tell me how to calculate the size of all files in a directory created in a certain year?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
J
jcmvbkbc, 2018-04-23
@a000_000a

calculate the size of all files in a directory created in a certain year?

- "Size of all files" - ambiguous, are you interested in the sum of sizes, or the volume occupied by files on the disk? The second is usually larger than the first.
- "In the directory" - only in it, or in nested directories too?
- "Created" -- not possible on most filesystems. You can "last modified".
In total, the amount in bytes occupied on the disk by files in a given directory and subdirectories, last modified in 2017, can be calculated, for example, like this:
find /home/user/repo -type f -newermt 2017-01-01 -not -newermt 2018-01-01 -print0 | du --files0-from=- -B 1 -c

7
7ADRAY, 2018-04-23
@7ADRAY

ll| grep 2017| awk '{tot+=$5}; END {print "Total size: " tot}'

Accordingly, at the beginning of the command, you can specify the path to the desired folder

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question