Replace all occurrences of dash to the left of a colon using sed
5
votes
5
answers
3216
views
I have the following values in a
config.yml
file:
scratch-org-def: config/project-scratch-def.json
assign-permset: false
permset-name:
run-apex-tests: true
apex-test-format: tap
delete-scratch-org: false
show-scratch-org-url: true
I need to replace all occurrences of dashes (-) to the left of the colon (:) with underscores (_).
I've tried sed '/.*: /s/-/_/g' config.yml
but it replaces all dashes (including the config/project-scratch-def.json
).
I've tried sed '/^[^:]*:/s/-/_/g' config.yml
, hoping to stop at the colon, but it does the same.
Asked by Wade
(153 rep)
Feb 10, 2018, 05:11 PM
Last activity: May 12, 2025, 06:57 PM
Last activity: May 12, 2025, 06:57 PM