Is it possible to do a join on multiple fields of two files? I am trying to do something like join -t, -1 2,3 -2 2,3 -o 2.1,2.2,2.3,1.3 filea fileb
I want the join to be on columns 2 and 3 of filea and columns 2 and 3 of fileb.
What is hapenning is that the second file that I want to do the join... (1 Reply)
i wanna combine 2 files that need to use join(need to use -a1 -a2) to produce a new file and also need to sort the new file in numerical order by ID.
The format of 2 files is:
Filename: Prac1
# Results for Prac1. The format is:
# 12345677 10
20693680 10
20179687 9
20781637 5
21907894 6
... (1 Reply)
Hi Guys,
I have a file as follows:
1 2 3
There are 5 spaces between 1 and 2 and one space between 2 and 3.
I want:
123
How can I do this using awk?
I tried using: (8 Replies)
Hi, I need help with the join command
I have 2 files that I want to join on multiple fields.
I want to return all records from file 1
I also want empty fields in my joined file if there isn't a match in file 2
I have already sorted them so I know they are in the same order.
file1 ... (0 Replies)
My input is as below:
1|2|3|a02 test|303
2|2|4|1002 a05 ind|303
4|3|5|ind|30
Output
1|2|3|a02test|303
2|2|4|a05ind|303
4|3|5|ind|30
I used command:
I am getting above output. Is there any simple way using awk to acheive this.
Thanks.
Please use code tags! (6 Replies)
Hi All,
I am looking for an awk script to do the following
Join the fields together only if the first 4 fields are same.
Can it be done with join function in awk??
a,b,c,d,8,,,
a,b,c,d,,7,,
a,b,c,d,,,9,
a,b,p,e,8,,,
a.b,p,e,,9,,
a,b,p,z,,,,9
a,b,p,z,,8,,
desired output:
... (1 Reply)
Hi
I have a file as below
<field1> <field2> <field3> ... <field_num1> <field_num2>
Trying to sort based on difference of <field_num1> and <field_num2> in desceding order and print all fields.
I tried this and it doesn't sort on the difference field .. Appreciate your help.
cat... (9 Replies)
Hi All,
Seeking for your assistance on how to combine two fields if there's a comma between them.
What i did was, extract the records from database.
file1.csv(extracted from db)
82|Supplies Station, Inc.|112012|KARISSA APPAREL, INC. - 112012|NON TRADE F/A AND... (2 Replies)
Discussion started by: znesotomayor
2 Replies
LEARN ABOUT REDHAT
join
JOIN(1) FSF JOIN(1)NAME
join - join lines of two files on a common field
SYNOPSIS
join [OPTION]... FILE1 FILE2
DESCRIPTION
For each pair of input lines with identical join fields, write a line to standard output. The default join field is the first, delimited
by whitespace. When FILE1 or FILE2 (not both) is -, read standard input.
-a SIDE
print unpairable lines coming from file SIDE
-e EMPTY
replace missing input fields with EMPTY
-i, --ignore-case ignore differences in case when comparing fields
-j FIELD
(obsolescent) equivalent to `-1 FIELD -2 FIELD'
-j1 FIELD
(obsolescent) equivalent to `-1 FIELD'
-j2 FIELD
(obsolescent) equivalent to `-2 FIELD'
-o FORMAT
obey FORMAT while constructing output line
-t CHAR
use CHAR as input and output field separator
-v SIDE
like -a SIDE, but suppress joined output lines
-1 FIELD
join on this FIELD of file 1
-2 FIELD
join on this FIELD of file 2
--help display this help and exit
--version
output version information and exit
Unless -t CHAR is given, leading blanks separate fields and are ignored, else fields are separated by CHAR. Any FIELD is a field number
counted from 1. FORMAT is one or more comma or blank separated specifications, each being `SIDE.FIELD' or `0'. Default FORMAT outputs the
join field, the remaining fields from FILE1, the remaining fields from FILE2, all separated by CHAR.
AUTHOR
Written by Mike Haertel.
REPORTING BUGS
Report bugs to <bug-coreutils@gnu.org>.
COPYRIGHT
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICU-
LAR PURPOSE.
SEE ALSO
The full documentation for join is maintained as a Texinfo manual. If the info and join programs are properly installed at your site, the
command
info join
should give you access to the complete manual.
join (coreutils) 4.5.3 February 2003 JOIN(1)