You are not logged in.
I'm a real newb at bash, been at this for hours now trying to figure it out, really tired so maybe this is easy to figure out, don't hate on me.
tc1="sda"
tc2="sdb"
tc3="sdc"
tc4="sdd"
VOL="${tc$1}"
DEV="/dev/"
TCVOL="$DEV$VOL"
echo "$TCVOL"
The first user input $1 is gonna be a number.
I want that number to be applied to a new var after "tc", that var is then gonna be one of the "tcX" vars.
I then somehow want the contents of the "tcX" var (for example "sda") to be put into the $VOL var.
I've tried like a million different ways to make the $VOL var, but can't figure it out.
My goal is:
If user input is "1", the script should echo "/dev/sda".
If user input is "2", the script should echo "/dev/sdb".
And so on.
Offline
Variable substitution only works on one variable at a time: vscollect=tc$1, and its syntax is ${!vscollect}.
Offline
Thank you so much!
The "!" did the trick!
Last edited by jonazdnb (2011-03-04 09:02:58)
Offline