I have an Awk string-compare problem and have searched the internet and forums for a solution i could use but cannot find a solution i understand to make work with my particular problem:
I need to compare (field1 field2 field3 of File1) against (field1 of File2) and if they match print out... (6 Replies)
I'm trying to compare two files using AWK, where if field2 of both files match, replace field1 of file1 with field1 of file2 and if there is no match just print the line of file1.
file1.txt (has empty first field)
:ABBATOM:B:H:1992
:ABBA TROJAN:B:H:1993
:ABBES FIRST HOPE:B:M:1997
:ABBEYS... (4 Replies)
Hello,
I've never used awk before, but from what I've read, it will best suit what I'm trying to do. I have 2 files. I need to replace strings in file1 with the first column of a matching string in file2. Below are examples:
File1:
random-string1
1112
1232
3213
2131
random-string2... (7 Replies)
I have very limited coding skills but I'm wondering if someone could help me with this. There are many threads about matching strings in two files, but I have no idea how to add a column from one file to another based on a matching string.
I'm looking to match column1 in file1 to the number... (3 Replies)
I have 2 files with 7 fields and i want to print the lines which is present in file1 but not in file2 based on field1 and field2.
Logic: I want to print all the lines, where there is a particular column1 and column2. And we do not find the set of column1 and column2 in file2.
Example: "sc2/10... (3 Replies)
Hi, I wanted to add each row of file2.txt to entire length of file1.txt given the sample data below and save it as new file. Any idea how to efficiently do it. Thank you for any help.
input file
file1.txt file2.txt
140 30 200006 141 32
140 32 200006 142 33
140 35 200006 142... (5 Replies)
I want to print only the lines in file2 that match file1, in the same order as they appear in file 1
file1
file2
desired output:
I'm getting the lines to match
awk 'FNR==NR {a++}; FNR!=NR && a' file1 file2
but they are in sorted order, which is not what I want:
Can anyone... (4 Replies)
I am trying to use awk to find all the $2 values in file2 which is ~30MB and tab-delimited, that are between $2 and $3 in file1 which is ~2GB and tab-delimited.
I have just found out that I need to use $1 and $2 and $3 from file1 and $1 and $2of file2 must match $1 of file1 and be in the range... (6 Replies)
Trying to use awk to:
update $2 in file2 with the $2 value in file1, if $1 in file1 matches $13 in file2, which is tab-delimeted. The $2values may already be the same so in that case nothing happens and the next line is processed.
There are exactly 4,605 unique $13 values. Thank you :).
... (4 Replies)
Discussion started by: cmccabe
4 Replies
LEARN ABOUT MINIX
join
JOIN(1) General Commands Manual JOIN(1)NAME
join - relational database operator
SYNOPSIS
join [-an] [-e s] [-o list] [-tc] file1 file2
DESCRIPTION
Join forms, on the standard output, a join of the two relations specified by the lines of file1 and file2. If file1 is `-', the standard
input is used.
File1 and file2 must be sorted in increasing ASCII collating sequence on the fields on which they are to be joined, normally the first in
each line.
There is one line in the output for each pair of lines in file1 and file2 that have identical join fields. The output line normally con-
sists of the common field, then the rest of the line from file1, then the rest of the line from file2.
Fields are normally separated by blank, tab or newline. In this case, multiple separators count as one, and leading separators are dis-
carded.
These options are recognized:
-an In addition to the normal output, produce a line for each unpairable line in file n, where n is 1 or 2.
-e s Replace empty output fields by string s.
-o list
Each output line comprises the fields specified in list, each element of which has the form n.m, where n is a file number and m is a
field number.
-tc Use character c as a separator (tab character). Every appearance of c in a line is significant.
SEE ALSO sort(1), comm(1), awk(1).
BUGS
With default field separation, the collating sequence is that of sort -b; with -t, the sequence is that of a plain sort.
The conventions of join, sort, comm, uniq, look and awk(1) are wildly incongruous.
7th Edition April 29, 1985 JOIN(1)