LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 07-15-2013, 10:35 AM   #1
mosiac
Member
 
Registered: Jan 2013
Distribution: RHEL
Posts: 54
Blog Entries: 1

Rep: Reputation: 4
Looking for best way to calculate group of file by specific date


So I'm trying to find out how many files have a date say "Jul 15" and then get the total amount of space they take up.

Currently I'm using something along the lines of

Code:
find /directory -type f -name "*.log*" -cmin -610 2> /dev/null | xargs du -b -h 2>/dev/null | awk '{total += $1; print $0} END{print total}'
But I really don't like having to use ctime and I'm wondering if there is a better way.

Thanks
 
Old 07-15-2013, 11:07 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Not sure this is better, I did change a few things though:
Code:
touch --date="2013-07-15 00:00:00" /tmp/token1
touch --date="2013-07-15 23:59:59" /tmp/token2
find /dirX -type f -newer /tmp/token1 -not -newer /tmp/token2 -exec stat -c%s {} \; | awk '{total += $1;print}END{print total}'
Main difference: The above uses 2 token files with a more precise date/time stamp, which are used by finds -newer option.
 
1 members found this post helpful.
Old 07-15-2013, 12:52 PM   #3
mosiac
Member
 
Registered: Jan 2013
Distribution: RHEL
Posts: 54

Original Poster
Blog Entries: 1

Rep: Reputation: 4
That's working perfectly. Thanks
 
Old 07-15-2013, 01:21 PM   #4
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
You're welcome

BTW: Can you put up the [SOLVED] tag.
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
copy a file with a specific date ust Linux - Newbie 3 06-26-2012 06:04 AM
[SOLVED] how to select date and some specific data from a log file shwhooda Linux - Newbie 2 06-25-2012 06:56 PM
IsThere a fridge, that we can program at specific date/time to unfreeze specific food frenchn00b General 3 07-21-2009 11:26 PM
Perl/bash - calculate date in future rose_bud4201 Programming 6 05-10-2009 05:59 AM
How to make a specific command(s) work for specific users or group only naren_0101bits Linux - General 3 08-28-2005 05:22 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:25 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration