The Stack Overflow podcast is back! Listen to an interview with our new CEO.
1 of 2

Filter YAML file content using sed/awk

I have a text file with the following content in it.

$ cat hosts.yml

I would like to filter hosts listed under [prod_env] file in bash. I tried with sed, awk and grep with my limited knowledge, but I am not sure how to filter them.

Example: I would like to print hosts under prod_env and dev_env. so the final output would be: