Search remotely and send the results to local machine

By John C. Zastrow

If you want to grep (search) through a log file while you’re ssh’d in
to a server and then get that output to yourself on your workstation. I
usually do “grep … > ~/file.txt” and then scp it over.

But you can also do:

ssh remotehost -l remoteuser “grep regexpr logfile” > localfilename

Or if you are already on the remote but want the file to end up locally:

grep … ssh localhost cat \>file.txt

~ from the gang at Milwaukee LUG