Solved

file size

Posted on 2011-03-04
6
281 Views
Last Modified: 2012-06-22
Hi,

How can I get the file size of all the files starting feb 2, 2011 up to feb 8, 2011?

Cheers!
0
Comment
Question by:mikesteven
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 3

Expert Comment

by:alphabet26
ID: 35039441
as a sum of the file sizes or just display them?
0
 
LVL 4

Expert Comment

by:Tomun
ID: 35039500
Try this:
find . -maxdepth 1 -type f  -newermt "2011-02-02 00:00" ! -newermt "2011-02-07 23:59" -exec /usr/bin/du -ch {} +

Open in new window


you might need to change the path to du (which du) to find it.
0
 

Author Comment

by:mikesteven
ID: 35039861
yes please, as a sum
0
Veeam gives away 10 full conference passes

Veeam is a VMworld 2017 US & Europe Platinum Sponsor. Enter the raffle to get the full conference pass. Pass includes the admission to all general and breakout sessions, VMware Hands-On Labs, Solutions Exchange, exclusive giveaways and the great VMworld Customer Appreciation Part

 
LVL 4

Expert Comment

by:Tomun
ID: 35039924
The sum is at the bottom of the output of the command I gave. It may not work if there are too many matching files though as it passes them all as arguments to du and you might run into the maximum command line length.

Remove the -maxdepth 1 if you want to look in subdirectories too.
0
 

Author Comment

by:mikesteven
ID: 35040769
Tomun, there's gonna be like 6,000 files matching will that work?
0
 
LVL 4

Accepted Solution

by:
Tomun earned 500 total points
ID: 35040892
II think it'll split the command into multiple lines if it's too long so add a "| grep total$" to the end to show only the totals and if you get more than one total you'll just have to add them together.

Here it is in full (I fixed an issue with the dates too).

find . -maxdepth 1 -type f  -newermt "2011-02-01 23:59:59" ! -newermt "2011-02-07 23:59:59" -exec /usr/bin/du -ch {} +|grep total$

Open in new window


The dot after the find command means the current directory, change that if you want to look somewhere else.

If that's not good enough there may be a better way to do it, but it might be more than a one liner. Try it and see how you get on.
0

Featured Post

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have a server on collocation with the super-fast CPU, that doesn't mean that you get it running at full power. Here is a preamble. When doing inventory of Linux servers, that I'm administering, I've found that some of them are running on l…
Using 'screen' for session sharing, The Simple Edition Step 1: user starts session with command: screen Step 2: other user (logged in with same user account) connects with command: screen -x Done. Both users are connected to the same CLI sessio…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
Suggested Courses

622 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question