Results 1 to 2 of 2
Hi, in the below command a variable $DOMAIN is not being substituted.
Code:
sed -n '1h;1!H;${;g;s/\n# BEGIN: vhost $DOMAIN.*END: vhost $DOMAIN//g;p;}' filename
How can I make it work? Thanks....
- 09-09-2010 #1Just Joined!
- Join Date
- Sep 2010
- Posts
- 2
[SOLVED] pass variables to sed
Hi, in the below command a variable $DOMAIN is not being substituted.
How can I make it work? Thanks.Code:sed -n '1h;1!H;${;g;s/\n# BEGIN: vhost $DOMAIN.*END: vhost $DOMAIN//g;p;}' filenameLast edited by danstefan; 09-09-2010 at 01:12 PM. Reason: problem solved
- 09-09-2010 #2Just Joined!
- Join Date
- Sep 2010
- Posts
- 2
[SOLVED] pass variables to sed
I found a solution:
Code:STR_BEGIN='1h;1!H;${;g;s/';STR_END='//g;p;}';STR="$STR_BEGIN\n# BEGIN: vhost $DOMAIN.*END: vhost $DOMAIN$STR_END" sed -n "STR" filename


Reply With Quote