I tried to parse data from switch configuration files
vlan 1727 name SQ5506-15 by port
tagged ethe 8/1 to 8/2
untagged ethe 1/13
!
vlan 2105 name SQ5620-7007(BR2) by port
tagged ethe 8/1 to 8/2
untagged ethe 1/17
!
interface ethernet 1/13
port-name SQ5506-15.nic0
rate-limit input fixed 10000000
sflow forwarding
!
interface ethernet 1/17
port-name SQ5620-7007.nic0
rate-limit input fixed 100000000
sflow forwarding
!
At first I parse interface number by device name and switch path with this command
INTERFACE=`awk '/^vlan(.*)'"$DEVICE "'(.*)/,/^!/' "$SWITCH_PATH" | awk '/untagged/{print $3}'`
Then I tried to get rate limit from interface that I parse from above with this command
RATELIMIT=`awk '/^interface ethernet '"$INTERFACE"'\r(.*)/,/^!/' "$SWITCH_PATH" | awk '/rate-limit/{print $4}'`
But it is showing an error
awk: /^interface ethernet 1/13\r(.*)/,/^!/
awk: ^ backslash not last character on line
If $INTERFACE is single number like "74" it will work but if $INTERFACE has forward slash like "1/13" it will showing an error as above. I have tried with put direct interface number and found that I have to put backslash before forward slash in interface number like this
RATELIMIT=`awk '/^interface ethernet '"1\/13"'\r(.*)/,/^!/' "$SWITCH_PATH" | awk '/rate-limit/{print $4}'`
I also tried with awk -v too but no luck. It is showing no error but still can't get value what I want
RATELIMIT=`awk -v INTERFACE="$INTERFACE" '/^interface ethernet INTERFACE\r(.*)/,/^!/' "$SWITCH_PATH" | awk '/rate-limit/{print $4}'`
I tried with every possible changing quote and double quote but still no luck. Can someone help me this?