LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 12-26-2007, 11:07 AM   #1
bostonthunder777
Member
 
Registered: Jul 2007
Posts: 30

Rep: Reputation: 15
script to sum all partition size


Hi, I need to sum all the partition size so that I get total data size.

Filesystem 1M-blocks Used Available Use% Mounted on
/dev/sda2 3336 3011 156 96% /
/dev/sda1 99 12 83 12% /boot
none 125 0 125 0% /dev/shm

So the output shuold be 3336+99+125


Thanks for your help
 
Old 12-26-2007, 11:18 AM   #2
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654
Awk is a handy program for calulating totals from commands like df or ls -l:
Code:
df /dev/sda6 | awk 'BEGIN { total=0 } NR>1 { total = total + $2 } END {print total}'

Last edited by jschiwal; 12-26-2007 at 11:19 AM.
 
Old 12-26-2007, 12:00 PM   #3
bostonthunder777
Member
 
Registered: Jul 2007
Posts: 30

Original Poster
Rep: Reputation: 15
Awesome! Thank you.. I will have to learn it.
 
Old 12-26-2007, 12:19 PM   #4
kzutter
Member
 
Registered: Nov 2007
Location: Carson City, NV USA
Distribution: Various, but always Debian based
Posts: 70

Rep: Reputation: 15
...+125 ??? Huh???

Why are you adding this (shared memory) to the rest (physical disk partitions)?

Last edited by kzutter; 12-26-2007 at 12:21 PM.
 
Old 12-26-2007, 03:26 PM   #5
bostonthunder777
Member
 
Registered: Jul 2007
Posts: 30

Original Poster
Rep: Reputation: 15
true bro.. I gotta grep -v it..
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Size in superblock is different from the physical size of the partition cyberfishee Linux - Hardware 16 08-12-2012 01:40 PM
Added second harddrive as a partition, but now the partition size is wrong.. mlsbraves Linux - General 5 08-17-2005 08:10 PM
file system size larger than fysical size:superblock or partition table corrupt klizon Linux - General 0 06-18-2004 04:18 PM
Total partition size - User partition size is not equals to Free partition size navaneethanj Linux - General 5 06-14-2004 12:55 PM
fdisk partition size differs from mounted partition size jimieee Linux - General 3 10-15-2003 03:10 AM


All times are GMT -5. The time now is 10:40 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration