4 ms·
While I myself am not a purist, some people would consider this an instance of UUOC: http://porkmail.org/era/unix/award.html http://porkmail.org/era/unix/award.
by rzzzt 8y ago
While I myself am not a purist, some people would consider this an instance of UUOC: http://porkmail.org/era/unix/award.html http://porkmail.org/era/unix/award.html
> localhost:~$ ssh remoteserver "grep badstuff.php /var/log/nginx/access.log"
- Matt3o12_ 8y agoThe only reason I (and probably many other people) prefer cat | grep instead of just using grep is because it is much easier to change the search term this way. With cat, it’s only a ctrl-W away from using a different term. If I only used grep, i would have to move my cursor which can get pretty annoying with a long file path. 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.