I have a text file with the following content in it.
$ cat hosts.yml [prod_env] foo.example.com bar.example.com [stage_env] foo_stage.example.com bar_stage.example.com [dev_env] foo_dev1.example.com dev2_bar.example.com
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:
foo.example.com bar.example.com foo_dev1.example.com dev2_bar.example.com