Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6250131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:21:54+00:00 2026-05-24T13:21:54+00:00

My script: #!/bin/sh cp -f host.tpl host.conf mkdir -p /var/www/$1 server_replace=s,{server_name},$1,g sed -i $server_replace

  • 0

My script:

#!/bin/sh

cp -f host.tpl host.conf
mkdir -p /var/www/$1

server_replace="s,{server_name},$1,g"
sed -i $server_replace host.conf

alias_replace="s,{server_alias},$2,g"
sed -i $alias_replace host.conf

File in which i’m doing replacemants (vhost.tpl):

<VirtualHost 0.0.0.0:80>
    ServerName {server_name}
    ServerAlias {server_alias}
    DocumentRoot /var/www/{server_name}
</VirtualHost>

It works fine when I’m creating vhost with one server alias

./vhost.sh domain.com www.domain.com

But when I want to have more aliases

./vhost.sh domain.com "www.domain.com m.domain.com"

script fails with message like

sed: -e expression #1, char 31: unterminated `s' command

Do I have to escape space character in some way to use it in replacement string?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T13:21:55+00:00Added an answer on May 24, 2026 at 1:21 pm

    Just put a pair of double quotes around the $alias_replace reference:

    sed -i.bkp "$alias_replace" host.conf
    

    It should do the trick. You just need to do it in the second sed call but I would strongly suggest you tho quote both variables.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I call this PHP script from the command line: /usr/bin/php /var/www/bims/index.php projects/output and
Linux bash script: #!/bin/bash function Print() { echo $1 } var=* Print $var Execution
Suppose a shell script (/bin/sh or /bin/bash) contained several commands. How can I cleanly
Here is my script: #!/bin/bash echo Digite o local em que deseja instalar o
I have this Perl script sitting in the cgi-bin folder of my Apache server:
The following script #!/usr/bin/Rscript --vanilla x <- c(4.5,6.4,7.2,6.7,8.8,7.8,9.6,7.0,5.9,6.8,5.7,5.2) fertilizer<- factor(c('A','A','A','A','B','B','B','B','C','C','C','C')) crop <- factor(c('I','II','III','IV','I','II','III','IV','I','II','III','IV')) av
Here is my script #!/usr/bin/env ruby if __FILE__ == $0 `cd ..` puts `ls`
I have a Perl script called replaceUp: #!/usr/bin/perl search=$1 replace=$2 find . -type f
I have a script that looks like this #!/bin/bash function something() { echo hello
I have a simple linux script: #!/bin/sh for i in `ls $1` do echo

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.