This does the trick in bash, but *not* in sh/dash:
DM_NAME=ubuntu--vg-ubuntu--lv t=${DM_NAME//--/_} vg=${t%-*}; vg=${vg/_/-} lv=${t#*-}; lv=${lv/_/-} echo "/dev/$vg/$lv"
This does the trick in bash, but *not* in sh/dash:
DM_NAME= ubuntu- -vg-ubuntu- -lv
t=${DM_NAME//--/_}
vg=${t%-*}; vg=${vg/_/-}
lv=${t#*-}; lv=${lv/_/-}
echo "/dev/$vg/$lv"