Echo a string with a variable in it without expanding/evaluating it
If you need $date
inside the variable var:
var='file.$date.txt'
That will keep the $ inside the variable:
$ echo "$var" | grep '\$'
file.$date.txt
Use single quotes around variables to prevent shell expansion. Example echo '$file'
will not expand $file
.
Edit after comment below:
You can escape the $
sign int the var
variable with var="file.\$DATE.txt"
.