Hello Experts,
I have two files called "old" and "new". My old file contains 10 lines and my new file contains 10 + "n" lines.
The first field in both these files contain ID. I sort these two files on ID. I am interested in only the lines that are in the new file and not in old.
I tried the below but was not successful
awk -F"\t" '{a[$] = $0} END { for (x in a) { print a[x] } }' maout > nodup
I have attached a file which gives an example of how my input files look like and the output i expect
Any suggestions would be appreciated.
Many Thanks in advance.
With awk:
awk 'NR==FNR{a[$0];next}!($0 in a)' old new
With grep:
grep -v -f old new
Hello Franklin,
Many thanks for your reply.
I tried both awk and grep commands but get syntax errors.
For the grep command the error is
>grep -v -f old new
grep: illegal option --f
For the awk command this is what i get
>awk 'NR==FNR{a[$0];next}!($0 in a)' old new
awk: syntax error near line 1
awk: bailing out near line
could you let me know where i am going wrong please.
Thanks again
diff can help you...
diff old new
6a7,9
> cc_03 1 uio yui
> cc_04 1 qwe abc
> cc_04 2 abc xyz
Have you adjust the line with the your own filenames?
Use nawk or /usr/xpg4/bin/awk on Solaris.
Regards