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)
sed -i.bak -e 's/application: .*/&2/' app.yaml
&
在替换中替换为与regexp匹配的所有内容。
sed -i.bak -e '1s/ .*/ my-appid2/' app.yaml
在第1行中,将一个空格替换为任何内容,并以一个空格替换您的新应用名称。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.