rahrahruby
rahrahruby

Reputation: 693

Passing sed a variable in a bash script

I am writing a bash script that uses sed and I am trying to a variable to $db, but $db has ` around it. This keeps me from being able to pass it the variable.

sed -n '/^-- Current Database: `$db`/,/^-- Current Database: `/p' $path$infile > $path$outfile.sql

Thanks for your help

Upvotes: 0

Views: 159

Answers (1)

pobrelkey
pobrelkey

Reputation: 5973

Wrap the sed script in double rather than single quotes, and use backslashes to escape the backticks:

sed -n "/^-- Current Database: \`${db}\`/,/^-- Current Database: \`/p" $path$infile > $path$outfile.sql

Upvotes: 1

Related Questions