2

I would like to replace one (first line) in app.yaml file I have with bash. The file looks like below:

application: my-appid
version: 1
...

my-appid there should be replaced with my-appid2.

I tried to use

sed -i.bak -e "s/application: \.*/application: \ 2/" app.yaml

but in result I get application: 2my-appid.

How should I fix it? (my-appid shouldn't be hardcoded)

1
  • Why are you escaping the .? Commented Jun 5, 2014 at 21:02

2 Answers 2

3
sed -i.bak -e 's/application: .*/&2/' app.yaml

& in the replacement gets replaced with everything that matched the regexp.

Sign up to request clarification or add additional context in comments.

Comments

0
sed -i.bak -e '1s/ .*/ my-appid2/' app.yaml

On line 1, replace a space followed by anything, with a space followed by your new app name.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.