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
  • 40,956

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'