I have file and content has like below.
------------------------------------------------
##
servers:
# Start OF VM1
- host: "VM1"
queueFilters:
include: ["*"]
channelFilters:
include: ["*"]
# End OF VM1
# Start OF VM2
- host: "VM2"
queueFilters:
include: ["*"]
channelFilters:
include: ["*"]
# End OF VM2
---------------------------------------------------
I wanted to update parameter like include under queueFilter section : ["test1","test2","test3"]
only between the lines where from # Start OF VM1
to # End OF VM1
I tried with the command,
V1=VM1
V2="test1","test2","test3"
awk -F': ' '/# Start OF '$V1'/,/# End OF '$V1'/{if( $0 ~/include/ ) {if ( $2 ~ /\[\]/ ) {gsub(/\]/,"'$V2']")} else {gsub(/\]/,",'$V2']")}}}1' input.yaml
Could some one help me how to achieve this..