Re: Help -- how to get the difference of these two files
- From: Stephane CHAZELAS <this.address@xxxxxxxxxx>
- Date: Mon, 12 Feb 2007 07:53:32 GMT
2007-02-11, 19:04(-08), jzhang2006@xxxxxxxxx:
I have two files:[...]
file1 --
"John" "Hello" "World" "AE" "01-2007"
"John2" "Hello2" "World2" "AE2" "01-2007"
"John3" "Hello3" "World" "AE3" "01-2007"
"John4" "Hello4" "World4" "AE4" "01-2007"
"John5" "Hello5" "World5" "AE5" "01-2007"
file2 --
"John" "Hello" "World" "AE" "02-2007"
"John2" "Hello2" "World2" "AE2" "02-2007"
"John13" "Hello3" "World" "AE3" "02-2007"
"John14" "Hello4" "World4" "AE4" "02-2007"
"John15" "Hello5" "World5" "AE5" "02-2007"
What I need is to get the rows in file2 but not in file1. In addition
the comparision should not take the last filed as account (i.e.
"01-2007" and '02-2007" should not be considered). So in this case, I
wish to get:
"John13" "Hello3" "World" "AE3" "02-2007"
"John14" "Hello4" "World4" "AE4" "02-2007"
"John15" "Hello5" "World5" "AE5" "02-2007"
comm -13 file1 file2
if the files are sorted.
Non standard (bash, zsh, some kshs):
comm -13 <(sort file1) <(sort file2)
or (needs a system with /dev/fd/x):
sort file1 | { sort file2 | comm -13 /dev/fd/3 -; } 3<&0
See also:
sort file1 file2 | uniq -u
For lines that appear only once in the combined files.
--
Stéphane
.
- References:
- Help -- how to get the difference of these two files
- From: jzhang2006
- Help -- how to get the difference of these two files
- Prev by Date: Re: Check if current day is last saturday of a month, WITHOUT GNU date!
- Next by Date: Fs problem
- Previous by thread: Re: Help -- how to get the difference of these two files
- Next by thread: Re: Help -- how to get the difference of these two files
- Index(es):
Relevant Pages
|