Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Server
User Name
Linux - Server This forum is for the discussion of Linux Software used in a server related context.


  Search this Thread
Old 12-26-2007, 11:07 AM   #1
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
LQ Guru
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 671Reputation: 671Reputation: 671Reputation: 671Reputation: 671Reputation: 671
Awk is a handy program for calulating totals from commands like df or ls -l:
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
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
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
Registered: Jul 2007
Posts: 30

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


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 18 09-11-2016 08:48 AM
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 > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 04:02 AM.

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