Skip to content

Instantly share code, notes, and snippets.

@Gershon-A
Last active November 23, 2021 07:49
Show Gist options
  • Save Gershon-A/21412e466e9f5ef81f3c43df7d3f67da to your computer and use it in GitHub Desktop.
Save Gershon-A/21412e466e9f5ef81f3c43df7d3f67da to your computer and use it in GitHub Desktop.
AWS CodeBuild grep and sed yaml file
Example of replacing "tag" in helm values.yaml file in CodeBuild
```
# VALUE for tag in values.yaml is tag: "121212"
# NEW_TAG = 131313
# YAML_FILE = values.yaml
- "OLD_TAG=$(cat $YAML_FILE | grep -P 'tag:' | awk -F: '{ print $2 }' | sed 's/[\",]//g' | sed -e 's/^[[:space:]]*//')"
- echo OLD_TAG=$OLD_TAG
- sed -i "s|${OLD_TAG}|${NEW_TAG}|g" $YAML_FILE
- cat $YAML_FILE | grep tag
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment