I have a bash script that will temporarily store a string and uses it later within a command. The issue is that a lot of times the string will have !
or other non-alphanumerical characters and bash will then take them literally and does what bash would usually do with these characters.
So for the example of !
, it will try to run a command by doing History Substitution. I know that for that specific case I can just start the script with #!/bin/bash +H
, but I can't really account for all the possible characters, so how can I make bash use the values within a variable literally?
For example:
var=u134y123!3q54wtgf..314/sa|asd
/path/to/command -option $var
In this above case, how would I make it so bash doesn't think I'm doing History Substitution or I/O Redirection (due to the |
)?