Bash parameter expansion

Giles Orr gilesorr-Re5JQEeQqe8AvxtiuMwx3w at public.gmane.org
Sun Aug 22 22:36:11 UTC 2010


With Debian's recent change to the way it handles device names at
boot-up, I can't count on / being on sda anymore.  Today it's on sde,
but what I've read suggests that that may change.  This messes up my
automatic backup of the MBR, so I'm trying to figure out how to
determine this value automatically.  What I've come up with so far is
this:

tmp="$(mount | grep [[:space:]]/[[:space:]])" ; tmp1=${tmp%% *};
tmp2=${tmp1#/dev/} ; echo ${tmp2%%[0123456789]*}

Two questions: is there an easier way to determine this value without
pulling it out of mount like that?   And: is there an easier way to do
a string of Bash parameter expansions than assigning to multiple temp
values like that?  Even if there's an simple answer for the first
question I'd love an answer to the second as I've had to use that
messy method several times.  (I know I can do this in awk or perl more
easily: I'd like to stick to Bash here.)  Thanks in advance.

-- 
Giles
http://www.gilesorr.com/
gilesorr-Re5JQEeQqe8AvxtiuMwx3w at public.gmane.org
--
The Toronto Linux Users Group.      Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists





More information about the Legacy mailing list