total size

I have a directory that contains files like

aaa-2010-05-30.txt
ddd-2010-05-30.txt
www-2010-05-30.txt

i have total 2000 files, i need to calculate total size of files for *2010-05-30.txt like

aaa-2010-05-30.txt 200MB
ddd-2010-05-30.txt 10GB
www-2010-05-30.txt 4GB

Total 14.2 GB approx

Can any one suggest ?

You are on Linux:

stat -c %s *2010-05-30.txt  | awk '{sum += $1} END{print "total: ", sum}'

But it is showing

total: 1.25584e+10

how to convert in GB?

echo "scale=2;$sum/1024^3" | bc

where $sum is variable containing size in bytes

How to convert into bytes?

Because it is giving me parsing error.

Hi,

Probably you can try these steps

1) Go into the directory where you have all these files.

2) ls -l *2010-05-30.txt | awk ' { sum = sum + $5 } END {print "Total Size = "(sum/1024)/1024 "GB" }'

3) You will get the desired results.

Regards
Naree