Results 1 to 9 of 9
sfdisk -s
The above command provides whole drives with their size in blocks ...How can i find the size in bytes ?
Thanks,
karana...
- 07-23-2008 #1Just Joined!
- Join Date
- Jul 2008
- Posts
- 24
[SOLVED] linux finding all drives .
sfdisk -s
The above command provides whole drives with their size in blocks ...How can i find the size in bytes ?
Thanks,
karana
- 07-23-2008 #2
If you run it with 'sfdisk -l', you will get a line like
There you have the size of a block.Code:Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0
- 07-23-2008 #3Just Joined!
- Join Date
- Jul 2008
- Posts
- 24
scripts to get it
That is great .But unluckly my box linux doent have sfdisk .
I am going for fdisk -l
i would like to write a script that will provide me --disk name and disk size --in two dimensional arry or in a map .
i am new to scripting .
i tried
fdisk -l | grep Disk | grep "byte" | awk '{ print $1}
but i dont know how can i make it in an arraray.
I think i suceeded in conveying my questions in a good english . i wrote below to make u understand ...Sorry for my bad english .
clarification on "array"
string name[10];
int size[10] ;
for each i in name , correspoding i th element size indicates its size .....
- 07-23-2008 #4
- 07-23-2008 #5Just Joined!
- Join Date
- Jul 2008
- Posts
- 24
i am not mounting devices
i want to know full disk size ...and i am not mounting devices.
- 07-23-2008 #6Just Joined!
- Join Date
- Jul 2008
- Posts
- 24
but using df -h ,i can see only disk partions ..not disk size whole
- 07-23-2008 #7Linux User
- Join Date
- Jun 2007
- Posts
- 318
Here's a sample script that does what you want:
Code:#!/bin/bash typeset -i CT=0 TMPFLE=/tmp/tmp.tmp fdisk -l | grep "^Disk" > $TMPFLE while read LNE do CT=CT+1 DSK[$CT]="`echo "$LNE" | awk '{print $2}'`" SZE[$CT]="`echo "$LNE" | awk '{print $5}'`" echo "${DSK[$CT]} ${SZE[$CT]}" done < $TMPFLE echo "Disks found: $CT"
- 07-23-2008 #8Just Joined!
- Join Date
- Jul 2008
- Posts
- 24
Your answer is very interesting ....
Without creating tmp file , Can we do this ?
- 07-23-2008 #9Linux User
- Join Date
- Jun 2007
- Posts
- 318
Go to this tread for details:
http://www.linuxforums.org/forum/lin...thin-loop.html
EDIT: Forgot to mention that bash only supports one dimension arrays.



