0

How should I escape special characters in bash

flyway info -url="jdbc:redshift://server_name/db_name?ssl=true&sslfactory=com.amazon.redshift.ssl.NonValidatingFactory" -password='$PROD_PASSWORD'

PROD_PASSWORD=sf45$h)jY*@hj

I want to escape the dollar sign I tried escape \ and putting password='$PROD_PASSWORD' and also password="$PROD_PASSWORD" also %40.

dessert
  • 39,982

1 Answers1

1

Bash uses single quotes (') to avoid any special characters or the backslash (\) to escape a single character:

MY_VARIABLE='$foo'
echo "$MY_VARIABLE"

This will output $foo as will:

echo '\$foo'
  • 1
    Try to be more specific in answering the question, if possible. That means in this case: use variable names and assignments given in the question to avoid misunderstandings. – ADDB Oct 11 '18 at 22:41
  • I really don't want to condone such usage of variables or repeat his "production password" anymore to be honest! – Kristopher Ives Oct 11 '18 at 22:56