0

Below is a sed command used to replace the string $RUNTIME_DIR defined in redis.conf with an environment variable RUNTIME_DIR. But I always get an error

sed "s/\$RUNTIME_DIR/${RUNTIME_DIR}/" redis.conf
sed: 1: "s/$RUNTIME_DIR//use ...": bad flag in substitute command: 'u'

what is the correct way to use sed command with a variable as the replacement?

The content of the variable is /users/joey/dev/bigcrunch//runtime

6
  • Could you provide a sample line from redis.conf on how it is defined? Commented Jan 3, 2018 at 5:12
  • Could you also show us the content of the variable? My guess is that it contains a slash, and perhaps starts with /usr.... Commented Jan 3, 2018 at 5:30
  • Darn, @tripleee ... I was going to answer this as a templating question, not a sed one! :) Commented Jan 3, 2018 at 5:36
  • If you have another duplicate you want to link, I'll be happy to add it to the duplicate box if you don't yet have that privilege. (Oh, but you do, it seems.) Commented Jan 3, 2018 at 5:37
  • @tripleee, I've added an old standby to the dupe list.. This other one is older and almost identical question to this one, but I think it contains bad answers. Generally, I point people at mywiki.wooledge.org/TemplateFiles, which is about as authoritative a source as I know. I'll leave this comment for the wiki link. :) Commented Jan 3, 2018 at 5:47

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.