Diff between 2 files using awk

Hi Experts,

Could you please help me to find the difference between two files. I tried the diff command but did not like the output as it contained < and > signs and the line numbers. Is it possible to do something using awk?

I have two files, say File1.txt contains 5 values and File2.txt contains only 2 values of what File1.txt contains. I want a command or script that will list me the 3 missing values from File2.txt. Here are the examples

File1.txt
034J
025J-01
045k
089G-02
04J01

File2.txt
025J-01
04J01

Output.txt
034J
045k
089g-02

Any help is highly appreciated.

Thanks in advance

Easier with grep:

grep -vf file2 file1
034J
045k
089G-02

Or if you still want to use awk:

awk 'NR == FNR { A[$0]=1; next } !A[$0]' file2 file1
034J
045k
089G-02

or diff... 'man diff ' , I'm pretty sure there's a way to only output differences.
EDIT: probably not so useful...even
$diff --suppress-common-lines file1 file2
still outputs the line numbers as well.

Hi Scottn,

Many thanks for a quick response. I tried both you solutions.

with the grep I get the following message:

grep: illegal option -- f
usage: grep -hblcnsviw pattern file . . .

with the awk script i get
awk: syntax error near line 1
awk: bailing out near line 1

I used the commands exactly the way shown (obeviously replacing with the actual file names)

could you spot the mistake here please!!

Thanks again

Ah, solaris?

Use nawk or /usr/xpg4/bin/awk.

Two get only the entries found in file two you could use: -

diff -s <(sort file1.txt) <(sort file2.txt) | nawk ' /</{print $2}'

Hi,
Any solution to this problem?
I have the same doubt

Thanks