Solved

file size

Posted on 2011-03-04
6
277 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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
Fine Tune your automatic Updates for Ubuntu / Debian
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 find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

929 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

17 Experts available now in Live!

Get 1:1 Help Now