1
votes

I have the following shell script to replace the string in file

Port=7070

IP=1.1.1.1

NewBoshURL="var BOSH_URL = \"http://$IP:$Port/http-bind/\";"

sed -i 's/var BOSH_URL.*/'$NewBoshURL'/' index.html

It gives me error below

sed: -e expression #1, char 40: unknown option to `s'

1

1 Answers

2
votes

You have two problems here:

  • variable contains spaces, use double quotes to protect them
  • variable contains slash, try another delimit(such as @)

    sed -i "s@var BOSH_URL.*@$NewBoshURL@" index.html