How can I find space occupied by the incoming files for a date range,
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
My requirement is to find the space consumed and count of incoming files every month. So say If I have a directory "X" I would like to know the space and for the month of November
Following is the command we used to get the details.
cd x
Output1=$(find . -type f -newermt 2017-11-01 ! -newermt 2017-11-30 | wc -l)
Output2=$(find . -type f -newermt 2017-11-01 ! -newermt 2017-11-30 | du -sk)
echo "Count of file is $Output1 and Space occupied by files is $Output2 KB"
We ran the above command for 3 different ranges a) 1 Oct to 31st Oct , b) 1st Oct to 30th Nov, and c) 1st Nov to 30th Nov.
My expectation was a) + b) should be = C but it is not. Can you please share your views on this. Or can you please let me know if there is anything wrong with the command I am using. Or Please share if you have a better option for my requirement.
Count of file is 3679280 and Space occupied by files is 19766351768
Count of file is 6857725 and Space occupied by files is 19765912668
Count of file is 3063226 and Space occupied by files is 19765541452
shell-script find
add a comment |Â
up vote
0
down vote
favorite
My requirement is to find the space consumed and count of incoming files every month. So say If I have a directory "X" I would like to know the space and for the month of November
Following is the command we used to get the details.
cd x
Output1=$(find . -type f -newermt 2017-11-01 ! -newermt 2017-11-30 | wc -l)
Output2=$(find . -type f -newermt 2017-11-01 ! -newermt 2017-11-30 | du -sk)
echo "Count of file is $Output1 and Space occupied by files is $Output2 KB"
We ran the above command for 3 different ranges a) 1 Oct to 31st Oct , b) 1st Oct to 30th Nov, and c) 1st Nov to 30th Nov.
My expectation was a) + b) should be = C but it is not. Can you please share your views on this. Or can you please let me know if there is anything wrong with the command I am using. Or Please share if you have a better option for my requirement.
Count of file is 3679280 and Space occupied by files is 19766351768
Count of file is 6857725 and Space occupied by files is 19765912668
Count of file is 3063226 and Space occupied by files is 19765541452
shell-script find
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
My requirement is to find the space consumed and count of incoming files every month. So say If I have a directory "X" I would like to know the space and for the month of November
Following is the command we used to get the details.
cd x
Output1=$(find . -type f -newermt 2017-11-01 ! -newermt 2017-11-30 | wc -l)
Output2=$(find . -type f -newermt 2017-11-01 ! -newermt 2017-11-30 | du -sk)
echo "Count of file is $Output1 and Space occupied by files is $Output2 KB"
We ran the above command for 3 different ranges a) 1 Oct to 31st Oct , b) 1st Oct to 30th Nov, and c) 1st Nov to 30th Nov.
My expectation was a) + b) should be = C but it is not. Can you please share your views on this. Or can you please let me know if there is anything wrong with the command I am using. Or Please share if you have a better option for my requirement.
Count of file is 3679280 and Space occupied by files is 19766351768
Count of file is 6857725 and Space occupied by files is 19765912668
Count of file is 3063226 and Space occupied by files is 19765541452
shell-script find
My requirement is to find the space consumed and count of incoming files every month. So say If I have a directory "X" I would like to know the space and for the month of November
Following is the command we used to get the details.
cd x
Output1=$(find . -type f -newermt 2017-11-01 ! -newermt 2017-11-30 | wc -l)
Output2=$(find . -type f -newermt 2017-11-01 ! -newermt 2017-11-30 | du -sk)
echo "Count of file is $Output1 and Space occupied by files is $Output2 KB"
We ran the above command for 3 different ranges a) 1 Oct to 31st Oct , b) 1st Oct to 30th Nov, and c) 1st Nov to 30th Nov.
My expectation was a) + b) should be = C but it is not. Can you please share your views on this. Or can you please let me know if there is anything wrong with the command I am using. Or Please share if you have a better option for my requirement.
Count of file is 3679280 and Space occupied by files is 19766351768
Count of file is 6857725 and Space occupied by files is 19765912668
Count of file is 3063226 and Space occupied by files is 19765541452
shell-script find
edited Dec 7 '17 at 9:42
ilkkachu
50.1k676138
50.1k676138
asked Dec 7 '17 at 7:55
Anush
1
1
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
0
down vote
-newermt 2017-10-31
means "modified after October 31st, 00:00",! -newermt 2017-10-31
means "modified before or on October 31st, 00:00"
so the latter does not include files made during the day of October 31st. If you use -newermt 2017-10-01 ! -newermt 2017-10-31
, you'll miss the last day of the month.
$ find . -type f -newermt 2017-10-01 ! -newermt 2017-10-31
./oct30
$ find . -type f -newermt 2017-10-01 ! -newermt 2017-11-30
./oct30
./oct31
./nov01
$ find . -type f -newermt 2017-11-01 ! -newermt 2017-11-30
./nov01
You probably want -newermt 2017-10-01 ! -newermt 2017-11-01
to get the whole of October, but note that files created on exactly on midnight between Oct 31st and Nov 1st count for October. (This will probably not be an issue on any system with subsecond timestamps.)
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
-newermt 2017-10-31
means "modified after October 31st, 00:00",! -newermt 2017-10-31
means "modified before or on October 31st, 00:00"
so the latter does not include files made during the day of October 31st. If you use -newermt 2017-10-01 ! -newermt 2017-10-31
, you'll miss the last day of the month.
$ find . -type f -newermt 2017-10-01 ! -newermt 2017-10-31
./oct30
$ find . -type f -newermt 2017-10-01 ! -newermt 2017-11-30
./oct30
./oct31
./nov01
$ find . -type f -newermt 2017-11-01 ! -newermt 2017-11-30
./nov01
You probably want -newermt 2017-10-01 ! -newermt 2017-11-01
to get the whole of October, but note that files created on exactly on midnight between Oct 31st and Nov 1st count for October. (This will probably not be an issue on any system with subsecond timestamps.)
add a comment |Â
up vote
0
down vote
-newermt 2017-10-31
means "modified after October 31st, 00:00",! -newermt 2017-10-31
means "modified before or on October 31st, 00:00"
so the latter does not include files made during the day of October 31st. If you use -newermt 2017-10-01 ! -newermt 2017-10-31
, you'll miss the last day of the month.
$ find . -type f -newermt 2017-10-01 ! -newermt 2017-10-31
./oct30
$ find . -type f -newermt 2017-10-01 ! -newermt 2017-11-30
./oct30
./oct31
./nov01
$ find . -type f -newermt 2017-11-01 ! -newermt 2017-11-30
./nov01
You probably want -newermt 2017-10-01 ! -newermt 2017-11-01
to get the whole of October, but note that files created on exactly on midnight between Oct 31st and Nov 1st count for October. (This will probably not be an issue on any system with subsecond timestamps.)
add a comment |Â
up vote
0
down vote
up vote
0
down vote
-newermt 2017-10-31
means "modified after October 31st, 00:00",! -newermt 2017-10-31
means "modified before or on October 31st, 00:00"
so the latter does not include files made during the day of October 31st. If you use -newermt 2017-10-01 ! -newermt 2017-10-31
, you'll miss the last day of the month.
$ find . -type f -newermt 2017-10-01 ! -newermt 2017-10-31
./oct30
$ find . -type f -newermt 2017-10-01 ! -newermt 2017-11-30
./oct30
./oct31
./nov01
$ find . -type f -newermt 2017-11-01 ! -newermt 2017-11-30
./nov01
You probably want -newermt 2017-10-01 ! -newermt 2017-11-01
to get the whole of October, but note that files created on exactly on midnight between Oct 31st and Nov 1st count for October. (This will probably not be an issue on any system with subsecond timestamps.)
-newermt 2017-10-31
means "modified after October 31st, 00:00",! -newermt 2017-10-31
means "modified before or on October 31st, 00:00"
so the latter does not include files made during the day of October 31st. If you use -newermt 2017-10-01 ! -newermt 2017-10-31
, you'll miss the last day of the month.
$ find . -type f -newermt 2017-10-01 ! -newermt 2017-10-31
./oct30
$ find . -type f -newermt 2017-10-01 ! -newermt 2017-11-30
./oct30
./oct31
./nov01
$ find . -type f -newermt 2017-11-01 ! -newermt 2017-11-30
./nov01
You probably want -newermt 2017-10-01 ! -newermt 2017-11-01
to get the whole of October, but note that files created on exactly on midnight between Oct 31st and Nov 1st count for October. (This will probably not be an issue on any system with subsecond timestamps.)
answered Dec 7 '17 at 9:42
ilkkachu
50.1k676138
50.1k676138
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f409409%2fhow-can-i-find-space-occupied-by-the-incoming-files-for-a-date-range%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password