Solved

file size

Posted on 2011-03-04
6
276 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
  • 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
Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

This is the error message I got (CODE) Error caused by incompatible libmp3lame 3.98-2 with ffmpeg I've googled this error message and found out sometimes it attaches this note "can be treated with downgrade libmp3lame to version 3.97 or 3.98" …
Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
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…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now