funguy
funguy

Reputation: 2160

Using double-quotes within double-quotes in bash

echo "set :stage, :${brand}
set :deploy_to, "/srv/www/${brand}"

Im in this strange situation where I need a dynamic value and this value has to be wrapped in quotes. So for example this:

set :deploy_to, "/srv/www/${brand}"

when dynamic information will be filled it will be something like:

set :deploy_to, /srv/www/sony

but this is wrong as in the script, which I am filling, it has to be a string so the end result has to be wrapped in quotes, it has to be this:

set :deploy_to, "/srv/www/sony"

If I use these quotes ' ' the dynamic information is not filled.

How can I solve this? Thanks.

Upvotes: 1

Views: 377

Answers (2)

Jonny
Jonny

Reputation: 81

Been a while since I did some bash, but can't you just escape the quotes with a backslash?

set :deploy_to, "\"/srv/www/${brand}\""

Upvotes: 1

Lars Fischer
Lars Fischer

Reputation: 10229

use \" like in

echo "set :stage, \"/srv/www/:${brand}\""

Upvotes: 2

Related Questions