I need to update the value of a specifc key (say, key2) in the yaml file using shell command. I am trying to use sed but it is working only if I have a specific value, for example, TBD in this case. But I want to update the value everytime irrespective of any value. Also my replacement string is stored in a variable. Can anybody suggest me what command shall I use?
hash.yaml file
---
key1: val1
key2: <TBD>
key3:
- val3_1
- val3_2
This is what I tried and works for me. But only if I have "TBD" as my search key.
sed -i "s;<TBD>;$var;g" hash.yaml