I'm trying to do something like
var=0
grep "foo" bar | while read line; do
var=1
done
Unfortunately this doesn't work since the pipe causes the while to run in a subshell. Is there a better way to do this? I don't need to use "read" if there's another solution.
I've looked at http://stackoverflow.com/questions/124167/bash-variable-scope which is similar, but I couldn't get anything that worked from it.