LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 11-04-2005, 02:47 AM   #1
Paul_R
LQ Newbie
 
Registered: Nov 2005
Posts: 4

Rep: Reputation: 0
merge two files


Hi Guys,

Im trying to create a backup mailserver for some cpanel servers.

This involves a file on backup server (/etc/secondarymx) containing the contents of a file (/etc/localdomains) from each other server wishing to use it.

I can copy the "localdomains" file over to the backup server which is fine but how do I merge the file contents to the "secondarymx" file without creating duplicate data.

The files are just domain lists with line breaks i.e.
domain1
domain2
domain3...

Thanks,

Paul

Last edited by Paul_R; 11-04-2005 at 03:45 AM.
 
Old 11-04-2005, 03:37 AM   #2
ashamril
Member
 
Registered: Jan 2003
Location: cyberjaya
Distribution: rh mdk deb fed suse
Posts: 99

Rep: Reputation: 15
# cat localdomains >> secondarymx
 
Old 11-04-2005, 03:46 AM   #3
Paul_R
LQ Newbie
 
Registered: Nov 2005
Posts: 4

Original Poster
Rep: Reputation: 0
Quote:
Originally posted by ashamril
# cat localdomains >> secondarymx
Sorry, I meant merge not append, I have edited my post.
 
Old 11-04-2005, 05:19 AM   #4
ns_sanish
LQ Newbie
 
Registered: Jun 2004
Posts: 9

Rep: Reputation: 0
after appending do a "sort -u" on the file to remove dups
 
Old 11-04-2005, 05:46 AM   #5
Paul_R
LQ Newbie
 
Registered: Nov 2005
Posts: 4

Original Poster
Rep: Reputation: 0
Quote:
Originally posted by ns_sanish
after appending do a "sort -u" on the file to remove dups
Hi,

Thanks for your help

I ran "sort -u data3" data3 being the final output file, it sorts it on the screen however does not write this to the file so data3 remains with duplicates.
 
Old 11-04-2005, 05:56 AM   #6
ns_sanish
LQ Newbie
 
Registered: Jun 2004
Posts: 9

Rep: Reputation: 0
ofcourse u will have to redirect the output of sort to another file and then overwrite the original with the new one.

sort -u secondarymx > secondarymx.tmp
mv secondarymx.tmp secondarymx
 
Old 11-04-2005, 06:15 AM   #7
Paul_R
LQ Newbie
 
Registered: Nov 2005
Posts: 4

Original Poster
Rep: Reputation: 0
Quote:
Originally posted by ns_sanish
ofcourse u will have to redirect the output of sort to another file and then overwrite the original with the new one.

sort -u secondarymx > secondarymx.tmp
mv secondarymx.tmp secondarymx
Thank you very much
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
batch append string to the end of a determined line in text files osio Programming 6 06-30-2005 09:28 AM
Trying to Append files to an already made Tar bluedevlx Linux - Newbie 10 11-04-2004 07:37 AM
proftpd allow append Bloged Linux - Newbie 1 09-16-2003 10:16 PM
Append lines? HELP! jimmytango829 Linux - Hardware 1 07-07-2003 11:06 PM
append cd's hotrodowner Linux - Software 1 09-08-2002 02:53 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 08:59 PM.

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