LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Append file (https://www.linuxquestions.org/questions/linux-newbie-8/append-file-681666/)

ust 11-06-2008 08:35 PM

Append file
 
I hv a file want to scp to another server , but I don't want to overwrite the remote file , I want to append this file to the original file , can advise what can i do ? thx

david1941 11-06-2008 09:00 PM

Here is a way:
ssh target.machine 'F=$(mktemp);scp source.machine:sourcefile $F ; cat $F >> targetfile ;rm $F'

Note: this will create the targetfile if it does not exist or append if it does. It is actually a scp being run on the target machine.

Dave

Rsearcy 11-06-2008 09:51 PM

Here's another way using cat and ssh instead of scp:

cat localfile | ssh user@remoteserver "cat >> remotefile"

Richard


All times are GMT -5. The time now is 06:03 PM.