Checking the total size of all files from a particular date

Hi

I have some set of files for a particular date. What is the command that I need to put in for finding the total size of all the files for that particular date. The following command is fetching me the size of all individual files seperately

du -h *20101010*
 
16M file1.20101010
120K file2.20101010
181M file3.20101010
1K file4.20101010
6.9M file5.20101010

How can I find the total size. Any help would be really appreciated. Thanks

du *20101010* | awk '{ T += $1 } END { print T }'

This will print blocks, not KB/MB/GB, I'll try and fix that.

Thanks for letting me know that. Is there any way that I can get in KB/MB/GB?

Try du -hc <files>

du -hc *201010* | tail -1 | awk '{print $1}'

If you're using awk, you don't need tail.

du -hc *201010* | awk '{ L=$1 } END { print L }'

This is what I have got

du: illegal option -- c

Please state what Operating System and version you have. I guess it's not unix, but some Linux variant?
There is much variation in the "du" command and I personally haven't seen one behave like your Post #1 and which won't take "-hc" as a parameter.

SunOS devinf.tdbank.com 5.10 Generic_144488-09 sun4u sparc SUNW,Sun-Fire-V890

Oracle have really messed up the Solaris manuals site.

There are two versions of "du":
/usr/bin/du
/usr/xpg4/bin/du
According to the "man" pages for Solaris 10 they both accept "-hs" .  If one doesn't work, worth trying the other one.

Possible way round this it to pipe the list (not expand the list on the command line):
ls *20101010* | du -hs

Do check that you don't have "du" aliased with parameters.

1 Like

Thanks ..That works. Appreciated.Many thanks methyl