I have a following script where variables($1) inside variable($ARG) needs to be substituted:
#! /bin/bash
ARGS="-enable-kvm -hda /root/"$1".raw -display vnc=:"$1""
do_start()
{
echo $ARGS
}
case "$1" in
start)
for i in {1..5}; do
do_start $i
done
;;
esac
However, if I execute the script with ./scriptname start then output is following:
-enable-kvm -hda /root/start.raw -display vnc=:start
-enable-kvm -hda /root/start.raw -display vnc=:start
-enable-kvm -hda /root/start.raw -display vnc=:start
-enable-kvm -hda /root/start.raw -display vnc=:start
-enable-kvm -hda /root/start.raw -display vnc=:start
How to substitute variable inside variable in case of bash?
$ARGSin definition ofdo_start()