Skip to main content
Became Hot Network Question
added 39 characters in body
Source Link

This sed expression works, but is there a better way to represent the white space in both the search pattern and replace string?

BRANCHTAG=7.17.9-main-5ee3e99d5ff002862d93728d821461033de1186d
PRIOR_VERSION=7.17.4
clear; sed "s/^    newTag: 7.17.4${PRIOR_VERSION}.*$/    newTag: ${BRANCHTAG}/" kustomization.yaml

I cannot just search on newTag as that would replace all newTag strings in the file

This sed expression works, but is there a better way to represent the white space in both the search pattern and replace string?

BRANCHTAG=7.17.9-main-5ee3e99d5ff002862d93728d821461033de1186d
sed "s/^    newTag: 7.17.4.*$/    newTag: ${BRANCHTAG}/" kustomization.yaml

I cannot just search on newTag as that would replace all newTag strings in the file

This sed expression works, but is there a better way to represent the white space in both the search pattern and replace string?

BRANCHTAG=7.17.9-main-5ee3e99d5ff002862d93728d821461033de1186d
PRIOR_VERSION=7.17.4
clear; sed "s/^    newTag: ${PRIOR_VERSION}.*$/    newTag: ${BRANCHTAG}/" kustomization.yaml

I cannot just search on newTag as that would replace all newTag strings in the file

edited tags
Link
Kusalananda
  • 355.8k
  • 42
  • 735
  • 1.1k
Source Link

ignore whitespace at the beginning of a search pattern

This sed expression works, but is there a better way to represent the white space in both the search pattern and replace string?

BRANCHTAG=7.17.9-main-5ee3e99d5ff002862d93728d821461033de1186d
sed "s/^    newTag: 7.17.4.*$/    newTag: ${BRANCHTAG}/" kustomization.yaml

I cannot just search on newTag as that would replace all newTag strings in the file