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,392
  • 12
  • 115
  • 163
user_01_02
  • 101
  • 1
  • 1

1 Answers1

0

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'
Kristopher Ives
  • 5,419
  • 2
  • 27
  • 36
  • 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