sample session using “variable expansion” with Bash shell

$com=world
$echo com
com
$echo $com
world
$x=hello
$echo ${x}{com}
hello{com}
$echo ${x}${com}
helloworld
$echo $x$com
helloworld
$echo ${x}world
helloworld
$echo ${x} world
hello world
$echo $x world
hello world
$echo $xcom

$echo $x com
hello com
$echo $x $com
hello world
$echo $x$com
helloworld
$echo $xcom

$echo ${x}com
hellocom
$


$your_id=${USER}-on-${HOSTNAME}
$echo "$your_id"
jeffrin-on-debian
$your_id=$USER-on-$HOSTNAME
$echo "$your_id"
jeffrin-on-debian
$echo ${USER}5
jeffrin5
$echo $USER5

$echo $USER 5
jeffrin 5
$echo $USER 5
jeffrin 5
$your_id=hello
$echo $your_id5

$echo $your_id 5
hello 5
$echo ${your_id}5
hello5
$

http://www.tldp.org/LDP/abs/html/parameter-substitution.html
http://guide.bash.academy/03.variables.html

Leave a comment

Your email address will not be published. Required fields are marked *