How to avoid lines in bash script

I am running a bash script that calls mysql. The password is incorrectly transmitted, I think I need to avoid special characters, for example, a hash or a dollar sign?

#! / bin / bash

USER = myuser
PASS = "# mypass $"

# ... call mysql
+3
source share
2 answers

Use "..."is already the right thing, but $should be escaped ( \$) if it is not followed by an "invalid" character. However, you also need to always have the variable in quotation marks, as in:

somecommand -p "$PASS"
+1
source

Try using "\" before the character you are trying to avoid.

#!/bin/bash

USER=myuser
PASS="#mypass\$"

# ... call mysql
+2
source

All Articles