05-19-2009
Okay, here is a sample, cut and pasted:
file 1
99997 410
99998 410
100000 410
100001 410
file 2
99997 2009-05
99998 2009-04
99998 2009-04
99998 2009-04
99998 2009-04
99998 2009-04
99998 2009-04
99998 2009-05
99999 2009-04
99999 2009-04
99999 2009-04
99999 2009-04
99999 2009-04
99999 2009-04
99999 2009-04
99999 2009-04
99999 2009-04
100000 2009-04
100000 2009-04
100000 2009-04
100000 2009-04
100000 2009-04
100000 2009-04
100000 2009-04
100000 2009-04
100000 2009-04
100000 2009-04
100000 2009-04
100000 2009-04
100000 2009-04
100000 2009-05
100001 2009-04
100001 2009-04
100001 2009-04
100001 2009-04
100001 2009-04
100001 2009-04
100001 2009-05
100002 2009-04
100002 2009-04
100002 2009-04
100002 2009-04
100002 2009-04
9 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi,
I am trying to join 2 files..viz
f1:
12~a1
13~a2
112~a3
1112~a4
f2:
12~fa2
13~fa2
112~fa3
1112~fa4
while I join..I just get 2 o/p..
12~a1~fa2
13~a2~fa2 (4 Replies)
Discussion started by: unisam
4 Replies
2. Shell Programming and Scripting
Greetings,
I am attempting to use the join command to produce a file from 2 sorted comma seperated files. Ex.:
FILE 1:
jane,dow
joe,blow
FILE 2:
jane,dow,50,50,20
joe,blow,29,53,25
spike,lee,50,91,05
I want the resulting file to be reconds in FILE 2 where the person exists in FILE... (4 Replies)
Discussion started by: Supial
4 Replies
3. Shell Programming and Scripting
Hi,
I am a new learner of join command. Some result really make me confused.
Please kindly help me.
input:
file1:
LEO oracle engineer 210375
P.Jones Office Runner ID897
L.Clip Personl Chief ID982
S.Round UNIX admin ID6
file2:
Dept2C ID897 6 years
Dept5Z ID982 1 year
Dept3S ID6 2... (1 Reply)
Discussion started by: summer_cherry
1 Replies
4. Shell Programming and Scripting
Hi
my problem is:
I've 2 files like:
file1:
file2
I'd like to get file_out:
I mean if the field is different from zero in the first file i want take that field also in the second(no matter if in the second is zero).
I tried with the join command but it doesn't work always and i don't... (2 Replies)
Discussion started by: Dedalus
2 Replies
5. Shell Programming and Scripting
Hello,
I am using join to merge two files together. The defaults usually works great
join file1 file2 However, sometimes file1 or file2 has more keys, which I want to keep.
file 1:
-1 z
0 a
1 b
2 c
file 2:
0 a2
1 b2
2 c2
3 c3
So I do
join -a1 -a2 file1 file2 But then you don't... (0 Replies)
Discussion started by: ayu
0 Replies
6. Shell Programming and Scripting
input1
a_a a/a 10 100
a1 a_a 20 200
b1 b_b 30 300
input2
a_a a/a xxx yyy
a1 a1 lll ppp
b1 b_b kkk ooo
output
a_a a/a 10 100 xxx yyy (2 Replies)
Discussion started by: ruby_sgp
2 Replies
7. UNIX for Dummies Questions & Answers
file1:
Toronto:12439755:1076359:July 1, 1867:6
Quebec City:7560592:1542056:July 1, 1867:5
Halifax:938134:55284:July 1, 1867:4
Fredericton:751400:72908:July 1, 1867:3
Winnipeg:1170300:647797:July 15, 1870:7
Victoria:4168123:944735:July 20, 1871:10
Charlottetown:137900:5660:July 1, 1873:2... (2 Replies)
Discussion started by: mindfreak
2 Replies
8. UNIX for Dummies Questions & Answers
Hi,
I have 20 tab delimited text files that have a common column (column 1). The files are named GSM1.txt through GSM20.txt. Each file has 3 columns (2 other columns in addition to the first common column).
I want to write a script to join the files by the first common column so that in the... (5 Replies)
Discussion started by: evelibertine
5 Replies
9. Shell Programming and Scripting
Hello All,
I am trying to join two files, each with differing delimiters. file1 has
doe, john 10.00 60.00 4.00 5.00
doe, jane 10.00 60.00 4.00 5.00
...while file2 has the following content:
doe, johnz 10.00::60.00:4.00:5.00
doe, janet 10.00:60.00::4.00:5.00
Currently, I have join... (2 Replies)
Discussion started by: techieg
2 Replies
JOIN(1) BSD General Commands Manual JOIN(1)
NAME
join -- relational database operator
SYNOPSIS
join [-a file_number | -v file_number] [-e string] [-j file_number field] [-o list] [-t char] [-1 field] [-2 field] file1 file2
DESCRIPTION
The join utility performs an ``equality join'' on the specified files and writes the result to the standard output. The ``join field'' is
the field in each file by which the files are compared. The first field in each line is used by default. There is one line in the output
for each pair of lines in file1 and file2 which have identical join fields. Each output line consists of the join field, the remaining
fields from file1 and then the remaining fields from file2.
The default field separators are tab and space characters. In this case, multiple tabs and spaces count as a single field separator, and
leading tabs and spaces are ignored. The default output field separator is a single space character.
Many of the options use file and field numbers. Both file numbers and field numbers are 1 based, i.e. the first file on the command line is
file number 1 and the first field is field number 1. The following options are available:
-a file_number
In addition to the default output, produce a line for each unpairable line in file file_number. (The argument to -a must not be
preceded by a space; see the COMPATIBILITY section.)
-e string Replace empty output fields with string.
-o list The -o option specifies the fields that will be output from each file for each line with matching join fields. Each element of
list has the form 'file_number.field', where file_number is a file number and field is a field number. The elements of list must
be either comma (``,'') or whitespace separated. (The latter requires quoting to protect it from the shell, or, a simpler
approach is to use multiple -o options.)
-t char Use character char as a field delimiter for both input and output. Every occurrence of char in a line is significant.
-v file_number
Do not display the default output, but display a line for each unpairable line in file file_number. The options -v 1 and -v 2
may be specified at the same time.
-1 field Join on the field'th field of file 1.
-2 field Join on the field'th field of file 2.
When the default field delimiter characters are used, the files to be joined should be ordered in the collating sequence of sort(1), using
the -b option, on the fields on which they are to be joined, otherwise join may not report all field matches. When the field delimiter char-
acters are specified by the -t option, the collating sequence should be the same as sort(1) without the -b option.
If one of the arguments file1 or file2 is ``-'', the standard input is used.
The join utility exits 0 on success, and >0 if an error occurs.
COMPATIBILITY
For compatibility with historic versions of join, the following options are available:
-a In addition to the default output, produce a line for each unpairable line in both file 1 and file 2. (To distinguish between
this and -a file_number, join currently requires that the latter not include any white space.)
-j1 field Join on the field'th field of file 1.
-j2 field Join on the field'th field of file 2.
-j field Join on the field'th field of both file 1 and file 2.
-o list ...
Historical implementations of join permitted multiple arguments to the -o option. These arguments were of the form ``file_num-
ber.field_number'' as described for the current -o option. This has obvious difficulties in the presence of files named ``1.2''.
These options are available only so historic shell scripts don't require modification and should not be used.
SEE ALSO
awk(1), comm(1), paste(1), sort(1), uniq(1)
STANDARDS
The join command is expected to be IEEE Std 1003.2 (``POSIX.2'') compatible.
BSD
April 28, 1995 BSD