Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 11-06-2008, 09:35 PM   #1
Senior Member
Registered: Mar 2003
Location: fasdf
Distribution: Debian / Suse /RHEL
Posts: 1,130

Rep: Reputation: 30
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
Old 11-06-2008, 10:00 PM   #2
Registered: May 2005
Location: St. Louis, MO
Distribution: CentOS6
Posts: 267

Rep: Reputation: 58
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.


Last edited by david1941; 11-06-2008 at 10:02 PM. Reason: Remove the temp file
Old 11-06-2008, 10:51 PM   #3
LQ Newbie
Registered: Nov 2008
Location: Indiana, USA
Distribution: openSUSE / SimplyMEPIS / Mandriva
Posts: 5

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

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

1 members found this post helpful.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to append columns form a column file in another file adam_blackice Programming 4 09-18-2007 12:33 AM
[Perl] append to new file noir911 Programming 5 02-08-2007 07:38 AM
Cannot append to file, even with sudo in /etc Micro420 Linux - General 4 01-23-2007 09:02 PM
> writes a new file, how to append? luwigie Linux - General 1 08-26-2004 09:42 PM
append to file d-rez Linux - Newbie 2 06-20-2002 05:55 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:42 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration