How to set value to variable with quotes and symbols literally and reproduced exactly

Viewed 25

I have a value

view/3dc84ea0-e9fc-11eb-841e-518effe6e821?_g=(filters:!(),refreshInterval:(pause:!t,value:0),time:(from:now-15m,to:now))&_a=(description:'',filters:!(('$state':(store:appState),meta:(alias:!n,disabled:!f,index:

I want to set it to a variable. When I tried it I got errors or missed some symbols. In powershell there is @''@ and the staff that inside is reproduced exactly like the value that I provided. Is there a way to do it with Bash?

1 Answers

For textual data, I like to use a here document with a quoted delimiter, all inside command substitution.

var=$(cat <<'EOF'
view/3dc84ea0-e9fc-11eb-841e-518effe6e821?_g=(filters:!(),refreshInterval:(pause:!t,value:0),time:(from:now-15m,to:now))&_a=(description:'',filters:!(('$state':(store:appState),meta:(alias:!n,disabled:!f,index:
EOF
)
Related