Results 1 to 5 of 5
Hi Everyone!
I am running into another problem that I would like some help on.
I want to compare 2 columns from 2 different files and then report what was ...
- 03-03-2008 #1Just Joined!
- Join Date
- Oct 2007
- Location
- Houston
- Posts
- 75
compare 2 columns from 2 different files
Hi Everyone!
I am running into another problem that I would like some help on.
I want to compare 2 columns from 2 different files and then report what was not found in file1 but was found in file2 to be reported to a 3rd file.
File 1
File 2Code:ACCT00600002 DESKTOP1\BACKUP OF FILES ON C$,SYSTEM STATE AND SERVICES DATABASE\ADMIN Friday TRT1 ACCT00600002 DESKTOP1\BACKUP OF FILES ON C$,SYSTEM STATE AND SERVICES DATABASE\ADMIN Monday TRT1 ACCT00600002 DESKTOP1\BACKUP OF FILES ON C$,SYSTEM STATE AND SERVICES DATABASE\ADMIN Saturday TRT1
File 3 (Desired Result)Code:ACCT00600002 DESKTOP1\BACKUP OF FILES ON C$,SYSTEM STATE AND SERVICES DATABASE\ADMIN ACCT00600002 DESKTOP1\BACKUP OF FILES ON C$,SYSTEM STATE AND SERVICES DATABASE\ADMIN ACCT00600002 DESKTOP1\BACKUP OF FILES ON C$,SYSTEM STATE AND SERVICES DATABASE\ADMIN ACCT00600003 SERVER1\BACKUP OF FILES ON C$,SYSTEM STATE AND SERVICES DATABASE\ADMIN
File #2 does not contain a day or a TRT vaule. That is normal. I am trying to find out what lines are not present based on Column 1 and Column 2 and have it report back those differences in the 3rd file.Code:ACCT00600003 SERVER1\BACKUP OF FILES ON C$,SYSTEM STATE AND SERVICES DATABASE\ADMIN
Also is there a way to do the opposite. Such as if it is not found in file2 delete it out of file1?
- 03-04-2008 #2Linux User
- Join Date
- Aug 2006
- Posts
- 458
what have you got so far?
- 03-04-2008 #3Just Joined!
- Join Date
- Oct 2007
- Location
- Houston
- Posts
- 75
I have tried this. But I think I have messed something up. It continues to brint every difference between the lines including what is in column 3 which is not what I want.
As far as the removal from file1 if it does not exist in file2 I have not yet started to work on it.Code:awk -F"\t" 'NR==FNR{++a[$1, $2];next}!a[$1, $2]' file1 file2 > file3
- 03-04-2008 #4Linux User
- Join Date
- Aug 2006
- Posts
- 458
remove -F"\t"
- 03-04-2008 #5Just Joined!
- Join Date
- Oct 2007
- Location
- Houston
- Posts
- 75


Reply With Quote
