help to get the biggest partition with awk


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting help to get the biggest partition with awk
# 1  
Old 07-20-2012
help to get the biggest partition with awk

Code:
# fdisk -l /dev/sda
 
Disk /dev/sda: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders, total 1953525168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x85bda12f
 
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1              63    62926604    31463271   83  Linux
/dev/sda2        62926605    83907494    10490445   83  Linux
/dev/sda3        83907495  1953520064   934806285   83  Linux

The size is END -START, how to get the biggest partition: /dev/sda3

Last edited by yanglei_fage; 07-20-2012 at 11:47 AM..
# 2  
Old 07-20-2012
The size is also in the Blocks columns, that will save you computing it.
# 3  
Old 07-20-2012
Quote:
Originally Posted by jlliagre
The size is also in the Blocks columns, that will save you computing it.
Thanks, I just want to use "-" haha

Lei
# 4  
Old 07-20-2012
Quote:
Originally Posted by yanglei_fage
Thanks, I just want to use "-" haha

Lei
If you just want for fun.. Here is a way : )
Code:
awk 'BEGIN {m=0} /^\// { m=($3-$2>m)?$3-$2:m} END {print m}'

# 5  
Old 07-20-2012
Why would you use "-" ?? Smilie
# 6  
Old 07-20-2012
Code:
BEGIN {m=0}

is unnecessary with awk as m value is already 0 at first use.

---------- Post updated at 13:58 ---------- Previous update was at 13:54 ----------

Quote:
Originally Posted by PikK45
Why would you use "-" ?? Smilie
One reason might be fdisk append + to the Blocks column if there is an odd number of sectors in the partition.
These 2 Users Gave Thanks to jlliagre For This Post:
# 7  
Old 07-20-2012
Quote:
Originally Posted by clx
If you just want for fun.. Here is a way : )
Code:
awk 'BEGIN {m=0} /^\// { m=($3-$2>m)?$3-$2:m} END {print m}'


can you point me where is wrong for mine
Code:
awk '/^\// {if ($3-$2>max) max=$3-$2 fi} END {print max}'

if I change to not use "-", it works

Code:
awk '/^\// {if ($4>max) max=$4 fi} END {print max}'

another quesion is

I want to out put /dev/sda3. which is the max partition
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

Shrink LVM partition & create new Linux Primary partition

Hello All, I have a Red Hat Linux 5.9 Server installed with one hard disk & 2 Partitions created on it as follows, /boot - Linux Partition & another is LVM - One VG & under that 5-6 Logical volumes(var,opt,home etc). Here my requirement is to take out 1GB of space from LVM ( Any logical... (5 Replies)
Discussion started by: gr8_usk
5 Replies

2. Shell Programming and Scripting

Find biggest values on replicates

Dear All I was wondering if someone of you know how to resolve an issue that I met. In particular I have a file like this: ENSMUSG01 chr1 77837902 77853530 ENSMUSG02 chr2 18780447 18811972 ENSMUSG02 chr2 18780453 18811626 ENSMUSG02 chr2 18807356 18811987 ENSMUSG03 chr3 142575634 142576538... (6 Replies)
Discussion started by: giuliangiuseppe
6 Replies

3. Shell Programming and Scripting

Grep 5 biggest column

please help, file1.txt id,week,ict,outgoing_call,blackberry_problem,gprs_problem,sms_problem,flash_problem,sinyal_lemah,blankspot,incoming_call,mms_problem,kualitas_suara,drop_call,data_probl em,cross_connect,connect_no_voice,vas_problem ,1,sumbagsel,96,127,52,70,28,29,21,18,18,8,5,3,0,0,3... (1 Reply)
Discussion started by: radius
1 Replies

4. Solaris

Partition overlaps another partition while creating new parition in solaris

hi all while formatting hard disk i am getting following error. Partition 1 ends at 266338338 It must be between 34 and 143374704. label error: EFI Labels do not support overlapping partitions Partition 8 overlaps partition 1. Warning: error writing EFI. Label failed. I have formatted the... (2 Replies)
Discussion started by: nikhil kasar
2 Replies

5. HP-UX

Biggest files on FS /

Hi! I'm using Unix HP I'm looking for a command which find the 20 (less or more) biggest files on / but which exclude every other files system Thanks;) (7 Replies)
Discussion started by: Castelior
7 Replies

6. Shell Programming and Scripting

Top 5 biggest file

Hi , I need to get a list of name and size , of the the top 5 biggest file under the current directory , in decending order Thank You (4 Replies)
Discussion started by: yoavbe
4 Replies

7. Shell Programming and Scripting

finding biggest number

I think my script is working but i am trying to understand while I am tracing to see if it's realli working.. can somebody please comment.. also. is there different way to write this in shell? sh -x findbiggestnum 1 2 3 + big=0 + big=1 + big=2 + big=3 + echo 3 3 big=0 ... (3 Replies)
Discussion started by: hankooknara
3 Replies

8. Solaris

top biggest files

hi all, is there any way how i can output the top 10-30 biggest files for all filesystem? using du -sh * is quite tedious since i have to move from 1 directory at a time. thanks (3 Replies)
Discussion started by: 3rr0r_3rr0r
3 Replies

9. UNIX for Dummies Questions & Answers

I've created a partition with GNU Parted, how do I mount the partition?

I've created a partition with GNU Parted, how do I mount the partition? The manual information at http://www.gnu.org/software/parted/manual/parted.html is good, but I am sure about how I mount the partition afterwards. Thanks, --Todd (1 Reply)
Discussion started by: jtp51
1 Replies

10. UNIX for Dummies Questions & Answers

The biggest newb ever...

Hi, all you unix people. I am a pretty advanced windows user, but I am curious about unix. Is there any reason I should attempt to acquire some form of unix for my home computer system? What sort of things is unix useful for? Unix is open source, right? Assuming that to be the case, I infer that... (3 Replies)
Discussion started by: BoneMalone
3 Replies
Login or Register to Ask a Question