I need to update values on the .yml file
For example, On below I need to modify only the version
name: dummyaml
description: >-
blah blah blah.
version: 1.2.3
environment:
sdk: '>=2.10.0 <3.0.0'
dependencies:
efts: ^2.0.4
transmogrify: ^0.4.0
dev_dependencies:
test: '>=1.15.0 <2.0.0'
I tried this
sed -i 's/^version:.*/version:'"$VERSION"'/' xy.yaml
got below error
sed: 1: "xy.yaml": extra characters at the end of x command
CodePudding user response:
sed 's/^\(version: \).*$/\15.6.7/' input.yml
sed 's/PATTERN/REPLACEMENT/'
: PATTERN matches something from the source. REPLACEMENT is what you now want to appear in the modified content.\1
: is the content of the text in parentheses in the PATTERN. Here,version:
^
: starts with$
: ends with5.6.7
: some version I put there, put your own desired value
IMPORTANT: this will only work if you only have version: SOMETHING
in the file. If you have more than one version:
line, it will modify both!