Not sure if the title is precise. Let's say I have a variable with a string:
var=C:\Windows\file.exe
And I'd like to print it's value as if it were a literal string, i.e. I want to see this on the screen:
C:\Windows\file.exe
But, of course, the usual ways to print a variable don't do that:
echo $var
C:Windowsfile.exe
echo "$var"
C:Windowsfile.exe
echo '$var'
$var
Is it possible to do that?
The problem is that the backslashes are being operated on by shell at definition time, not when you are evaluating the variable later. You need to quote the declaration i.e. use any shell escaping mechanism to escape the
\
s.Here is what you are doing:
Here is what you need: