I want to find the index of a word in a sentence (in my case it is a list of args)
...
elif [[ "$#" -gt "0" ]]
then
    ALL_ARGS="$@"
    echo ${ALL_ARGS} | grep -b -o target | sed 's/:.*$//'
    # 14
    TARGET_INDEX=`${ALL_ARGS} | grep -b -o target | sed 's/:.*$//'`
    # error
    # forganize.sh: line 45: .: -n: invalid option
    # .: usage: . filename [arguments]
    echo $TARGET_INDEX
...
It works in echo but I can't assign it to a variable.
Also if there is any other way to find index please let me know.
 
    