Hi All,
I am a newbie to Shell scripting. Please help me with the Following problem,
1. I have two files with the same name in different locations in the same machine.
Eg: /root/testfolder/a ---- location 1
/tmp/testfolder/a ----- location 2
2. I want to compare the files in location 1 and location 2.
Eg: diff /root/testfolder/a /tmp/testfolder/a
(Please suggest the best way using diff )
3. I must append only the lines missing in location 1(i.e. /root/testfolder/a) without losing any content of location 1.
Eg:
File in location 1
/root/testfolder/a)
Added line in Location 1
This is a test Script
But i am stuck.Please help
This is Added line to LOCATION 1(/root/testfolder/a)
File in location 2
/tmp/testfolder/a)
Added Line in the Location 2 (/tmp/testfolder/a)
This is a test Script
But i am stuck.Please help
This is added line for testing in LOCATION 2(/tmp/testfolder/a)
Executing diff command:
diff /root/testfolder/a /tmp/testfolder/a
Say output of the diff command looks like this:
1c1
< Added line in Location 1 (/root/testfolder/a)
---
> Added Line in the Location 2 (/tmp/testfolder/a)
4c4
< This is Added line to LOCATION 1(/root/testfolder/a)
---
> This is added line for testing in LOCATION 2(/tmp/testfolder/a)
Here,
I am concerned only to append those lines starting with ">" to the correct lines of /root/testfolder/a
Expected result in /root/testfolder/a
Added Line in the Location 2 (/tmp/testfolder/a)
Added line in Location 1
This is a test Script
This is added line for testing in LOCATION 2(/tmp/testfolder/a)
But i am stuck.Please help
Please help me develop a shell script to solve the above posted problem.
Thanks in advance
Karthick.