LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   how to append contents of one file to another existing file (https://www.linuxquestions.org/questions/programming-9/how-to-append-contents-of-one-file-to-another-existing-file-684059/)

amit_pansuria 11-17-2008 09:26 AM

how to append contents of one file to another existing file
 
suppose I have two files list1.cfg and list2.cfg
both files contains differentrecords details
like
List1.cfg
NAME1:25:C:NAME LINE1:
NAME2:25:C:NAME LINE2:
CITY:25:C:City:
STATE:2:C:State:
ZIPCODE:5:N:ZIPCODE:
PHONE1:12:C:HOME PHONE:
PHONE2:12:C:BUSINESS PHONE:

list2.cfg
NAME1:25:C:NAME LINE1:
NAME2:25:C:NAME LINE2:
PHONECNTR:2:N:Number of attemmpts at calling RECALLNUMBER
PHONESTATR:1:C:PHONESTAT of the current RECALLNUMBER
ZONEPHONER:1:C:Time zone of the current RECALLNUMBER
LASTDATER:10:D:Date of last attempt on RECALLNUMBER
LASTTIMER:8:T:Time of last attempt on RECALLNUMBER
LASTSTATR:2:C:Stat of last attempt on RECALLNUMBER
FRSTDATER:10:D:Date of first attempt to call RECALLNUMBER
FRSTTIMER:8:T:Time of first attempt to call RECALLNUMBER
FRSTSTATR:2:C:Stat of first attempt to call RECALLNUMBER

Now I want to append contents list2.cfg to list1.cfg(It ispposible using cat list2.cfg >>list1.cfg) but I want to check if content of (record) in list2.cfg is present in list1.cfg then dont append it otherwise append it.

How do I write such shell script in efficient way
Regards,
Amit

AuroraCA 11-17-2008 10:01 AM

Oh, come on. What's with all the homework? This is the easiest thing to do in Linux and a simple Google or reading your text will unveil the answer. Now go and read your books and do your own homework.


All times are GMT -5. The time now is 12:56 PM.