For my case I ended up doing something like:

```bash
code=$(grep -ci 'text' file.sh 2>&1 > /dev/null; echo $?)
echo $code
0
```

Works if you are only interested in the return code and you are willing to discard. ```stdout``` and ```stderr```