I have a .yml
file and it has content like below:
env_values:
stage: build
before_script: some-value
So I need to read and get the values for stage
and before_script
, so they will have build
and some-value
respectively.
Is there a good easy workaround in bash scripting to read this file and get the values?
Assume your .yml file is t.yml
, this Bash script gets the 2 values you need:
arr=($(cat t.yml | grep "stage:"))
stage=${arr[1]}
echo $stage
arr=($(cat t.yml | grep "before_script:"))
before_script=${arr[1]}
echo $before_script
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments