I need to get the next word of a word in a string. I tried to write a script but it's not working. And it's good if you suggest me any other alternatives to achieve this.
#!/bin/bash opts="OPTS=\"-name user -age 20 -where Asia -eats Brains\"" echo $opts ok="0" for word in $opts; do if [ "$word" = "-where" ] ; then if [ "$ok" = "1" ] ; then echo $word break fi ok="1" fi done
I want to get the word after "-where". But above script not working. I didn't understand where I'm missing. Thanks.