Compare two text files and Only show the differences

Hi experts,
I'mvery new to shell scripting and learning it now

currently i am having a problem which may look easy to u :slight_smile:

i have two files
File 1:
Start :Thu Nov 19 10:33:09 2009
ABCDGFSDJ.txt
APDemoNew.ppt
APDemoOutline.doc
ARDemoNew.ppt
ARDemoOutline.doc

File 2:
Start :Thu Nov 19 10:33:20 2009
ABCDGFSDJ.txt
APDemoNew.ppt
ARDemoNew.ppt
ARDemoOutline.doc

i should find the difference in file 2 compare to file 1
If any file missing, shell script should indicate the the missed file and write it in another text file(ex error.txt)
shell script should not compare the first line (date) for both test file(file1 and file2)

for example the output should be like in Error.txt
File missing :
APDemoOutline.doc

i would really appreciate if anyone can help me..

man diff
man grep ## look at the -f option

use diff. man diff for more info

I tried diff...but fail to get my desired output..
Can someone guide me with it with proper coding as example??
thnks

diff file1 file 2 |grep "^<" > error.txt

oh thanks you..
But how to remove the first and also last line from comparing??

Will this help you?

$sdiff a b | grep '<' > Error.txt

Thanks to all :slight_smile:

---------- Post updated at 10:05 PM ---------- Previous update was at 01:45 AM ----------

Thanks to all :slight_smile:
i successfully resolved my problem with your help and guide.

But i got one new problem now.
Using diff and sdiff function i can get the the correct output in error.txt..
but when i execute the script file again later, the errors in error.txt are disappears and re-write it with new errors.
Is there any other way that i can keep adding my errors in my error.txt without deleting the previous error??
and of course the current error should be in top..

Hope i can find help in this matter..

Use the append redirection operator:

... >> error.txt

If you want the current error to be in the top of the file,

You should try something like this.. This could be one of the crude ways to do..

$ cp Error.txt Error.txt.tmp
$ sdiff a b  | grep '<' >  a ## a is some temporary file.
$ cat a Error.txt.tmp > Error.txt

Using vimdiff command we can see the difference between the two files.

it will highlight the different lines in two windows.