Search code examples
shellunixksh

Concat digit to variable's and display it


I want to add a suffix (0) to variable containing a value in Kshell using shell scripting and then display the variable+suffix on screen

For e.g

abc.ksh 35 14063

What I tried is

var=$2
echo " ( value should be $var\0) "

OUTPUT should be 140630

But it is not working for me..What am i missing in it.


Solution

  • If you need to delineate variable names to be expanded inside a double-quoted string containing other elements, use ${...}, i.e., enclose the variable name in {}:

    echo "${var}0"
    

    This applies to all Bourne-like (POSIX-compatible) shells, such as bash, zsh, and dash.