Here is a simplified version of my problem.

```
if (echo "AA BB CC" | awk '{ print $1 $2 }' | grep -q "B"); then
   echo $2
fi

```

I would like to make `$2` available in bash, so I can use it elsewhere in the script.

Can that be done?

**Update**

I realized that I had simplified the problem too much. The awk expression should have been `awk '{ print $1 $2 }'` instead of just `awk '{ print $2 }'` which I originally posted.