Print only records from file 2 that do not match file 1 based on criteria of comparing column 1 and column 6
Was trying to play around with following code I found on other threads but not too successful
Code:
NR==FNR If we are reading the first file (The variables NR and FNR are only equal when reading the first file)
A[$1]=$2 store the second field in array a using the index of the first field
next proceed to read the next record
A[$1] if A[$1] exists (using the $1 of the second file)
$2=A[$1] FS $2;print then append FS (a comma) followed by A[$1] (using the $1 of the second file)
Fs=, set the input file seperator to "~"
OFS=, set the output file seperator to "~"
Code:
Last edited by radoulov; 08-02-2011 at 03:02 PM..
Reason: Code tags!
but this takes into account identical matching records not being printed.
The records are not exact duplicates but records have duplicate values in certain columns. So how can i have it compare the files and not print records in second file based on comparing column 1 and olumn 6?
I don't understand why you don't want 789..., 345..., 678... and 901... lines and want the line with 456...12/22/2017.
And lines with 012 have 7 fields, not 6. It's possible to fix this but maybe it is a mistake?
Hi
Does anyone know of an efficient way to index a column of data in file2 to print the coresponding row in file1 which corresponds to the data in file2 AND 30 rows preceding and after the row in file1.
For example suppose you have a list of numbers in file2 (single column) as follows:... (6 Replies)
Hi all , I have two files : dblp.xml with dblp records and itu1.txt with faculty members records. I need to find out how many dblp records are related to the faculty members. More specific: I need to find out which names from itu1.txt are a match in dblp. xml file , print them and show how many... (4 Replies)
Friends,
I have data sorted on id like this
id addressl
1 abc
2 abc
2 abc
2 abc
3 aabc
4 abc
4 abc
I want to pick all ids with addressesses leaving out duplicate records. Desired output would be
id address
1 abc
2 abc
3 abc
4 abc (5 Replies)
I'm trying to use awk to do the following. I have file1 with many lines, each containing 5 fields describing an individual set. I have file2 which is a template config file with variable space holders to be replaced by the values in file1. I would like to substitute each set of values in file1 with... (6 Replies)
Is it possible to print the records that has only 1 value in 2nd column.
Ex:
input
awex1 1
awex1 2
awex1 3
assww 1
ader34 1
ader34 2
output
assww 1 (5 Replies)
File1 row is same as column 2 in file 2.
Also file 2 will either start with A, B or C.
And 3rd column in file 2 is always F2.
When column 2 of file 2 matches file1 column, print all those rows into a separate file.
Here is an example.
file 1:
100
103
104
108
file 2:
... (6 Replies)
Hi All,
I have two files say file1 and file2.
I want to check the number of records in file1 and if its atleast 2 (i.e., 2 or greater than 2 ) then I have to check records in file2 .If records in file2 is atleast 1 (i.e. if its not empty ) i have to set some conditions .
Could you pls... (3 Replies)
Hello all,
Would appreciate if someone can help me out on the following requirement.
INPUT FILE:
--------------------------
TPS REPORT
abc def ghi
jkl mon pqr
stu vrs lll
END OF TPS REPORT
TPS REPORT
field1 field2 field3
field4 field5 field6 (8 Replies)
As part of a bigger task, I had to read thru a file and separate records into various batches based on a field. Specifically, separate records based on the value in the batch field as defined below. The batch field left-justified numbers.
The datafile is here
> cat infile
12345 1 John Smith ... (5 Replies)