1833334 Members
3304 Online
110051 Solutions
New Discussion

append file

 
haeman
Frequent Advisor

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
3 REPLIES 3
Ninad_1
Honored Contributor

Re: append file

Hi,

You would need to do this in multiple steps -
1. Copy the file to remote machine to temporary file (using scp)
2. Append the temporary file to the original file on the remote machine (u can use ssh)

OR

1. get the remote file to your local machine
2. append to the file locally
3. scp to remote machine.

I would prefer 1st option.

Regards,
Ninad
Suraj K Sankari
Honored Contributor

Re: append file

Hi,
1st you scp your file into remote server.
scp yourfile hostname:/path
then
2nd
ssh hostname cat /path/youfile >> /path/appendfile


Suraj
Dennis Handly
Acclaimed Contributor

Re: append file

>Suraj: ssh hostname cat /path/youfile >> /path/appendfile

You would need to quote the redirection:
ssh hostname "cat /path/youfile >> /path/appendfile"