While I myself am not a purist, some people would consider this an instance of UUOC: http://porkmail.org/era/unix/award.html
> localhost:~$ ssh remoteserver "grep badstuff.php /var/log/nginx/access.log"
> localhost:~$ ssh remoteserver "grep badstuff.php /var/log/nginx/access.log"
That being said, only using grep is my preferred approach (if I don’t forget it) in script and “compact lines” (I.e ssh, watch, and everything that expects the command as a string).
If you are grepping a file multiple times, I would recommend to connect to the server anyways (because it is much faster). That being said, if this is a single occurrence, and saves you from the pitfalls of using the local grep instead of the remote one, your approach is preferable in that case.
You can also do it like this:
< myfile grep mypattern$ ^term1^term2^
Try it