Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

file size

Posted on 2011-03-04
6
Medium Priority
?
286 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 2000 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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
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…
Suggested Courses
Course of the Month13 days, 5 hours left to enroll

972 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