I am trying to append create a string that will be evaluated in the middle of a grep line. It is to find possible occurrences of different usernames within a certain file. However, I do not know how many usernames there will be. So, I cycle through the array containing the list of usernames and return at output like so -e username -e username2 -e username3 that will be used in the grep line.However, this small piece of code seems to be giving me trouble. I've tried several approaches, but UNIX still believes I am trying to pass some sort of command:eGrepUsernames(){    returnString=;    for username in ${usernames[@]}    do        $returnString=$returnString -e $username #error given, command not found    done    echo returnString;}Later, I call the function over here:declare -a activeUsers=$( who | grep `eGrepUsernames` )What am I doing wrong in this case?
How to append string with dash?
grep;string
Your function was trying to evaluate $returnString on the left-hand side during the assignment; instead, you want:eGrepUsernames(){    returnString=;    for username in ${usernames[@]}    do        returnString=$returnString -e $username # this line changed    done    printf '%s ' $returnString;  ## so did this one}