hi all
basically i have file called rules which contain lines like below
/usr/bwmgr/utils/bwmgr em1 -x 735 -name user92 -addr 10.10.201.92 -addrmsk 255.255.255.252 -bwout 1024000 -bwin 2048000 -statsdevice user92 -stats
/usr/bwmgr/utils/bwmgr em1 -x 45032 -name user246 -addr 10.10.224.246 -bwboth 128000 -bwlink grp1 -statsdevice user246 -stats
i have a script which basically looks for the rule number and prints out the bandwidth (in and out)
sbpc# cat script.sh
#!/bin/sh
RuleNum=$1
/bin/cat /usr/home/bw/rules | /usr/bin/sed 's/^.*-x //' | /usr/bin/awk -v var=$RuleNum '$1==var {for(i=1;i<=NF;i++) {if($i=="-bwout") print $(i+3),$(i+1)}}'
sbpc#
so if i run the script and give input as 735, it will output
2048000 1024000
sbpc# sh script.sh 735
2048000 1024000
sbpc#
but if I do "sh script.sh 45032" then nothing will be printed out because the script cannot match the pattern "-bwout".
the file lines either contain the word "-bwout" or the word "-bwboth".
how can i change the script so that it will give either match "-bwout" and give output like its doing now or it will match "-bwboth" and print the next word.
so that if i do "sh script.sh 45032" then result should be 128000 .
with the same script i want to get output regardless of pattern "-bwout" or "-bwboth"
tia