> localhost:~$ ssh remoteserver "cat /var/log/nginx/access.log" | grep badstuff.php It would be much more traffic (and execution time) friendly, if you put pipe and grep to "" as well, so grep would be executed on remote server and ssh won't have to send the entire log to your machine. And I'd like to highlight the overwhelming awesomeness of ~/.ssh/config file. If you haven't heard about it or use shell alias instea…
The article does touch on that optimization: In this example the grep is being performed on the local system after the log file has been pushed across the ssh session. If the file is large it would be more efficient to run the grep on the remote side simply by enclosing the pipe and grep in the double quotes.
> localhost:~$ ssh remoteserver "grep badstuff.php /var/log/nginx/access.log"