Comparing files

I have a file called X, which contains the following:

10
100
200
300

I then have file Y, which containts the following:

10
200
500
800

I want to write a script that will compare the contents of Y with the contents of X and ONLY return values in Y that does not exist in X (output to file Z).

Could someone please point me in the right direction?

Thanks

awk ' FILENAME=="X" {arrx[$0]++}
       FILENAME=="Y" {arry[$0]++}         
     END {for (i in arry) 
         {if(arrx==0) {print i}  } }'  X Y > newfile

Sample run with code in t.awk:

If your fgrep supports the -f option, you can do

fgrep -vxf X Y

There are various more tedious ways to express this, e.g. using a sed script which you'd construct from the contents of X. Search the forums for "fgrep -f" "sed" or someething like that to see the numerous earlier threads on similar topics.

look into 'man comm'

thank you all for your replies

in this instance fgrep -vxf works the best. thank you era :b:

Does not this one address your issue?

comm -13 file1 file2