0

I am a beginner with sed and using to substitute variable in my config. Heres what I have :

# Create Jenkins Job
URL=$(echo https://github.net/$GITORG/$REPONAME.git)
#sed -e 's/terraform-test/'${REPONAME}'/g' -e 's/defaultslack/'${slackChannelName}'/g' -e 's/EMAIL/'${EMAIL}'/g' -i.bak ${JENKINS_CONFIG}
sed -e 's/terraform-test/'${REPONAME}'/g' -e 's/defaultslack/'${slackChannelName}'/g' -e 's/defaultgithub/'${URL}'/g' -i.bak ${JENKINS_CONFIG}

The first sed with # works fine and substitutes as it finds it, but the next sed

sed -e 's/terraform-test/'${REPONAME}'/g' -e 's/defaultslack/'${slackChannelName}'/g' -e 's/defaultgithub/'${URL}'/g' -i.bak ${JENKINS_CONFIG}

fails with the error:

sed: -e expression #3, char 24: unknown option to `s'

Any ideas why that would be ?

Scooby
  • 3,371
  • 8
  • 44
  • 84
  • 3
    REPONAME probably contains a `/`. Use a different delimiter. – William Pursell Aug 31 '16 at 14:51
  • Assign to your URL like this: `URL="https://github.net/$GITORG/$REPONAME.git"` – Tom Fenech Aug 31 '16 at 14:51
  • @WilliamPursell +1 though it must be `URL` that (understandably) contains a `/` : the error is about expression #3 – Aaron Aug 31 '16 at 14:52
  • when I print URL it is https://github.xx.net/djin-infrastructure/test1.git and even after I make the change that @TomFenech recs, still get the error – Scooby Aug 31 '16 at 15:10
  • 1
    Yeah, the problem (as in the linked question) is that the string contains `/`, so you need to use a different character instead of `/` for the `s/find/replace/` command. My earlier comment was only to say that you don't need to use `echo` to assign to your variable. – Tom Fenech Aug 31 '16 at 15:12
  • @TomFenech - I gotcha, that worked. Thanks! – Scooby Aug 31 '16 at 15:15

0 Answers0