Reputation: 318
how can I make the following work?:
var="-e" #is entered by a user
echo $var #should produce "-e" but does not, as the string is not escaped
The "-e" could for example be passed as input argument $1.
Thanks already :)
Upvotes: 0
Views: 1863
Reputation: 43
You could try printf
.
For example:
var="-e"
printf %s "$var"
should print out -e.
Upvotes: 1
Reputation: 3695
you probably want:
echo "${var}"
http://kvz.io/blog/2013/11/21/bash-best-practices/
Upvotes: 0