Next I use a for loop to sweep through the list to do a computation:
for VAR in $VAR_LIST
do
grep $VAR some.log | compute some value and return it
done
The problem is that instead of grepping “xxx aaa_bbb_ccc” it greps “xxx” and “aaa_bbb_ccc” separately. How do I just get each line and not every “word” in the line to be treated as a variable?
I don’t think the problem is with the grep expression and how I am “protecting” the variable name. I think it has to do with the variable defintion statement.
When you loop through your VAR_LIST variable the for loop is just going to break it into chunks based on whitespace, i.e. space or newline. Try splitting it into a list based on newlines first.