total size


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting total size
# 1  
Old 06-01-2010
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 ?
# 2  
Old 06-01-2010
You are on Linux:
Code:
stat -c %s *2010-05-30.txt  | awk '{sum += $1} END{print "total: ", sum}'

# 3  
Old 06-01-2010
But it is showing

total: 1.25584e+10


how to convert in GB?
# 4  
Old 06-01-2010
Code:
echo "scale=2;$sum/1024^3" | bc

where $sum is variable containing size in bytes
# 5  
Old 06-02-2010
How to convert into bytes?

Because it is giving me parsing error.
# 6  
Old 06-02-2010
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
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

How to count total HDD size of disk?

Hi, I am trying to fetch total HDD size through command line on solaris machine: bash-3.2# iostat -E sd0 Soft Errors: 0 Hard Errors: 0 Transport Errors: 0 Vendor: VMware Product: Virtual disk Revision: 1.0 Serial No: Size: 42.95GB <42949672448 bytes> Media Error: 0 Device... (1 Reply)
Discussion started by: omkar.jadhav
1 Replies

2. Solaris

Find the total size of multiple files

If I have a number of files in a directory, for example, test.1 test.2 test.3 abc.1 abc.2 abc.3 and I need to find the total file size of all of the test.* files, I can use du -bc test.* in Linux. However, in Solaris, du does not have the -c option. What can I do in Solaris to get... (11 Replies)
Discussion started by: learnix
11 Replies

3. Solaris

Need command to know the total size

:mad:i need command to know the total size of project in my system by Giga bit i try #du -s /*/projectname but i need total size for this project by G.B can you help me (6 Replies)
Discussion started by: ayman
6 Replies

4. Shell Programming and Scripting

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... (10 Replies)
Discussion started by: bobby1015
10 Replies

5. UNIX for Dummies Questions & Answers

get total size of files

as we use du - sh *.frm In This command It will show the list of files and size But I want the Total size that these files in directory with extension .frm How can we do This (6 Replies)
Discussion started by: kaushik02018
6 Replies

6. UNIX for Dummies Questions & Answers

I am trying to get the total size of a folder?

I am trying to get the total size of the folder using the below command but its not working. any ideas? du -bc <foldername>/|grep total|tr -s " "|cut -d" " -f1 the output i am getting is 78996 total but i just want it to be as 78996 please help (3 Replies)
Discussion started by: classic
3 Replies

7. Solaris

swap size, total disk space

Hi experts, In my solaris system when i run the command df -h i got the below response.I have some confusion which i want to share with you guys.1)there are two SWAP file system shows are they same or different?2)if i want to count the total disk space should i take both the swap space or only... (2 Replies)
Discussion started by: rafiassam
2 Replies

8. UNIX for Dummies Questions & Answers

Find total size for some files?

Hi, I'm newbie to Unix. I'd like to count the total size of those files in my directory by date. For example, files on this period 05/01/08 - 05/31/08. If possible can we count by byte instead of kb. if I use $ du - ks , it will add up all files in the dir. thanks, Helen (5 Replies)
Discussion started by: helen008
5 Replies

9. Solaris

command to find out total size of a specific file size (spread over the server)

hi all, in my server there are some specific application files which are spread through out the server... these are spread in folders..sub-folders..chid folders... please help me, how can i find the total size of these specific files in the server... (3 Replies)
Discussion started by: abhinov
3 Replies

10. HP-UX

total size taken by directory

HI ALL, i am a beginner in unix world. can anyone please tell me the way to find total size taken by each directory (including size of all subdirectories and files) present under /var. e.g what is space occupied by /var/adm , /var/admin etc. its a simple question but still i dont know the... (2 Replies)
Discussion started by: jyoti
2 Replies
Login or Register to Ask a Question