0
I am trying to figure out how to solve a problem with a "$" causing command expansion as part of a password field. How do you backslash the "$" when using command substitution (unknown) arguments? (i.e. $1, $2)
For example, in a script called 'testPass':
PASSWORD="$1"
echo $PASSWORD
If I type in:
testPass abcd123#$asd
Then the output is:
abcd123#
I have also tried single quotes (echo '$PASSWORD') as most people say online, however this just prints:
$PASSWORD
I have even tried using the printf command, which has also been mentioned online, as so:
printf '%q\n' '$PASSWORD'
However this does something similar, with the following output:
\$PASSWORD
I have searched for a long time to figure this out, however I am new to UNIX so I could be missing something I am unaware of. Please let me know if you have any ideas, thank you.
1
First of all, welcome to Super User! We are always glad to help, but you apparently have two Super User accounts: this one and this one. Please take the time to utilize the following Help Center tutorial and ask the Super User staff to merge your accounts: I accidentally created two accounts; how do I merge them?
– Run5k – 2019-10-29T00:40:00.453This question has an answer here: https://unix.stackexchange.com/a/379190/58455
– ecube – 2019-10-31T00:37:30.857