Find the answer to your Linux question:
Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    [SOLVED] pass variables to sed

    Hi, in the below command a variable $DOMAIN is not being substituted.

    sed -n '1h;1!H;${;g;s/\n# BEGIN: vhost $DOMAIN.*END: vhost $DOMAIN//g;p;}' filename
    How can I make it work? Thanks.
    Last edited by danstefan; 09-09-2010 at 01:12 PM. Reason: problem solved

  2. #2

    [SOLVED] pass variables to sed

    I found a solution:

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts