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.Script:#!/bin/bashopts=OPTS=\-name user -age 20 -where Asia -eats Brains\echo $optsok=0for word in $opts; do  if [ $word = -where ] ; then    if [ $ok = 1 ] ; then      echo $word      break    fi    ok=1  fidoneI want to get the word after -where. But above script not working. I didn't understand where I'm missing. Thanks.
Get very next word of a substring in a string
bash;shell script
I suggest to hire grep for this job:$ OPTS=\-name user -age 20 -where Asia -eats Brains\$ grep -Po -- '-where \K\w*' <<< $OPTSAsiaExplanation:-P: perl compatible regular expression-o: show only matching parts\K: drop everything before that point\w*: match word constituent (synonym for [_[:alnum:]])To add  to the list of matching characters:$ grep -Po -- '-eats \K[_\[:alnum:]]*' <<< $OPTSBrains