SSH – Append Local File to Remote File

ssh

I can use ssh or scp to append a remote file to a local file, but I cannot figure out how to do the reverse and append a local file to a remote server.

ssh remote.server cat /path/to/file >> locale-file

Works great (but not with globbing), but how do I reverse it?

Best Answer

cat localfile | ssh -t remote.server "cat - >> remote_file"

This will send the contents of localfile to the stdin of ssh.

cat - is then used to read this (- means stdin).

Related Question