1

how could I print a variable that has '*', I just want to print value and is taking it as "all"

example of what I want:

var=/home/us*r/
echo ${var}

Result:
/home/us*r/

example of what is doing

var=/home/us*r/
echo ${var}

Result:
/home/user/
/home/usar/
/home/usir/

any idea of how to print just the value of variable?

Javier Salas
  • 1,064
  • 5
  • 15
  • 38

1 Answers1

1

Put the variable expansion in double quotes:

echo "$var"

Curly braces are optional and they help if you want to interpolate a variable expansion in a string where it's surrounded by a character that's valid in a variable name, e.g.: echo "${var}_$var2", but it's double quotes that supress pathname expansion and field splitting.

See the Word Expansion section of dash(1) for more details.

Petr Skocik
  • 58,047
  • 6
  • 95
  • 142