awk comparing two files problem
- From: rachit7@xxxxxxxxx
- Date: Wed, 29 Aug 2007 11:52:45 -0700
Hello,
I got this code from one the the groups. Can somebody explain me what
exactly is happening here and how is that happening? Please provide a
detail explation. I am not good at awk when more than one files are
involved.
------------------------------------------------------------------------------------------------------
you want all the lines in file1 that are not in file2,
awk 'NR == FNR { a[$0]; next } !($0 in a)' file2 file1
If you want only uniq lines in file1 that are not in file2,
awk 'NR == FNR { a[$0]; next } !($0 in a) { print; a[$0] }'
file2
file1
---------------------------------------------------------------------------------------------------------
-RB
.
- Follow-Ups:
- Re: awk comparing two files problem
- From: Michael Tosch
- Re: awk comparing two files problem
- Prev by Date: Re: Help on ls
- Next by Date: Re: read and process a file each 3 lines
- Previous by thread: Pipe stderr and stdout
- Next by thread: Re: awk comparing two files problem
- Index(es):
Relevant Pages
|