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 Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s