Print summary or the total disk usage of conf file


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Print summary or the total disk usage of conf file
# 8  
Old 01-06-2012
try this

Code:
 find . -type f -name "*.conf" -ls | awk '{sum+=$7}END{print sum}'


Last edited by Scott; 01-06-2012 at 04:26 PM.. Reason: Code tags
# 9  
Old 01-06-2012
I hope this will solve your problem
Code:
$ du -sh *.pdf
604K    ch1-Introduction-2.pdf
100K    dist-03-4.pdf

$ du -sh *.pdf|awk '{sum+=$1}END{print sum}'
704

thanks,
venkat

Last edited by Scott; 01-06-2012 at 04:26 PM.. Reason: Code tags
# 10  
Old 01-06-2012
One way: Add up the size column from "ls -la".
This script assumes that the file size in your "ls -la" is in the 5th field and is in bytes.

Code:
size_tot=0
find /etc/ -type f -name \*\.conf -exec ls -ald {} \;| \
        awk '{print $5}'|while read size
do
        size_tot=$(( ${size_tot} + ${size} ))
done
echo "Total size (bytes) : ${size_tot}"


(Just noticed that this is similar to post #8 where the poster is finding the file size in the 7th field of -ls on that system).
# 11  
Old 01-06-2012
@methyl

You should do the size calculation within the awk that would avoid the additional while loop.

Smilie
# 12  
Old 01-06-2012
@ctsgnb
I like my while loops. This one had test code in it which was removed in the final version. If speed was important I'd look at streamlining but for what we are doing here imho easy-to-read is more important.
# 13  
Old 01-08-2012
find . -type f -name "*.conf" -ls | awk '{sum+=$7}END{print sum}' this works prefects except that i need it in human readable format any ideas
# 14  
Old 01-09-2012
On your system, what is the actual answer (and the units of the answer) when you run the script. What units should it be?

(My "find" does not have the "-ls" switch).
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

Total CPU usage on a server

hi, i am using solaris server. I want to find the total CPU usage on a server. Top command will give that result, but here that command is not working. So anyone can help me to find the total CPU usage. (2 Replies)
Discussion started by: Arasu123
2 Replies

2. UNIX for Dummies Questions & Answers

Total cpu usage in percent(%)

How to determine the total percentage cpu usage of a server having 4 cpu cores(quad core)? (3 Replies)
Discussion started by: proactiveaditya
3 Replies

3. UNIX for Advanced & Expert Users

How to check total disk usage ?

Hi.. What is the command to check total disk usage for specific directory in MG/GB/Byte ? As example i want to check disk usage for directory pproc ? Please help me.. Thank you, Baharin (3 Replies)
Discussion started by: bh_hensem
3 Replies

4. Shell Programming and Scripting

how to add up a total in a summary report?

Hi all i got a script up but i cant add up the summary report.. keep having synax error . mind helping me to take a look and tell me what went wrong.. i know is a bit long but i hope someone can hep me with it. thanks the error message come up when i try to run the sumary report.. i guess... (16 Replies)
Discussion started by: xiaojesus
16 Replies

5. Shell Programming and Scripting

Total usage memory by user

Hi, When running top on linux redhat machine , i see that i have 16gb of memory in my machine and about 14.5gb of memory are in use: Mem: 16395780k total, 14970960k used, 1424820k free, 370264k buffers Swap: 4192956k total, 25824k used, 4167132k free, 12029400k cached How can i... (3 Replies)
Discussion started by: yoavbe
3 Replies

6. Solaris

current CPU usage, memory usage, disk I/O oid(snmp)

Hi, I want to monitor the current cpu usage, monitor usage , disk I/o and network utlization for solaris using SNMP. I want the oids for above tasks. can you please tell me that Thank you (2 Replies)
Discussion started by: S_venkatesh
2 Replies

7. Shell Programming and Scripting

Detailed disk usage versus age summary

Hi, I'm posting my question here as I fele that what I am about to try to do must have been done already, and I don't want to re-invent the wheel. I have recently become responsible for monitoring disk space usage for a large file system. I would like to geenrate reports that will summise... (8 Replies)
Discussion started by: littleIdiot
8 Replies

8. UNIX for Dummies Questions & Answers

Disk Usage in GB and Unix command to find the biggest file/folder

Hi All, Please help me out 1) Command to find the disk usage in GB. I know that du -k will give in kilobites. 2) How to find the Biggest file/folder in a given set of files/folders. Thanks in advance Regards, Manas (8 Replies)
Discussion started by: manas6
8 Replies

9. HP-UX

How to summary one command's cpu usage?

I want to record one application's(like oracle etc...) CPU usage summary. I can filter by "ps". But how to sum? Thanks (1 Reply)
Discussion started by: jiarong.lu
1 Replies

10. Filesystems, Disks and Memory

How do you display summary of disk usage?

I am trying to create a command string that makes use of the du or df utilities to show block count in kilobytes (1024 bytes) instead of multiples of 512 bytes, any suggestions? Thanks..... (3 Replies)
Discussion started by: klannon
3 Replies
Login or Register to Ask a Question