This is an old revision of the document!


SSH commands

$ scp myfile.txt remoteuser@remoteserver:/remote/folder/

If the target folder (/remote/folder/) is not specified, it will copy the file to the remote user's home directory.

$ scp remoteuser@remoteserver:/remote/folder/remotefile.txt  localfile.txt

Using . as the copy target (replacing localfile.txt will copy the remote file to the current working directory using the same filename (remotefile.txt)

concatenate the contents of a file on local machine to another file on a remote server .

To concatenate the contents of a file on your local machine to another file on a remote server, you can use the scp command with the cat and tee commands, along with the -a option for tee.

Here's an example of how you can use scp, cat, and tee to concatenate the contents of a file on your local machine to another file on a remote server:

cat /path/to/local/file | ssh username@remote "tee -a /path/to/remote/destination"d

This will append the contents of /path/to/local/file on your local machine to the end of the file at /path/to/remote/destination on the remote server.

Alternatively, you can use the cat command with the >> operator to append the contents of a file on your local machine to another file on a remote server. Here's an example of how you can use this method:

ssh username@remote "cat >> /path/to/remote/destination" < /path/to/local/file

This will also append the contents of /path/to/local/file on your local machine to the end of the file at /path/to/remote/destination on the remote server.

  • user/madjid.1672930851.txt.gz
  • Last modified: 2023/01/05 15:00
  • by madjid