I think this will do what you want.

for disk in `egrep -o sd[a-z]*$ /proc/partitions`; do echo "$disk"; done

Timothy Martin


--- On Sun, 4/17/11, Bradley Willson <[email protected]> wrote:

> From: Bradley Willson <[email protected]>
> Subject: [SLL] A bash question
> To: "Linux LIst" <[email protected]>
> Date: Sunday, April 17, 2011, 2:54 PM
> I want to isolate the drives in
> /proc/partitions (i.e. sda, sdb, etc.) for
> another task (something other than echo :) ) but my test
> either returns
> nothing or everything and the kitchen sink, depending on
> whether I use a !=
> or == comparator...
> 
> for disk in `cat /proc/partitions | awk '{print $4}'|sed
> '1,2d'`
> >     do
> >         if [ $disk ==
> sd[a-z] ] then
> >         
>    echo $disk
> >         fi
> > done
> 
> 
> I know the 'cat' line gives me the raw data I want, it's
> the filter below
> that's broken.  I know it has to be something
> painfully simple, they
> typically are.
> 
> Any ideas?
> 
> Thanks in advance!
> 
> -- 
> Bradley Willson
> (Mobile) 425.891.2732, (Skype) 425.296.1687
> Es ist ein neuer Tag!
>

Reply via email to