04-09-2012
Thanks worked! But a condition needs to be added
Wow! it works! the only thing is it got a little complicated for me
I have to add a condidtion that if the third field in file 2 is 0, replace the 5th field in file1 by spaces.Any easy way of doing it,since I not very good in awk.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
i want to take position 19-24(only first line) from all files and need to compare any duplication is there or not.
If duplication, then i have to print the file names.
I have written to take the characters from 19-24 from all files. but how to compare ?
... (1 Reply)
Discussion started by: senthil_is
1 Replies
2. Shell Programming and Scripting
Hi,
I need to compare a column in two different csv files
file1
xyz.com,2/2/12,a,b,c
eg.com,2/2/23,a,b,ga
file2
1,2,ua,xyz.com
1,2,ua,abc.com
1,2,ua,eg.com
1,2,ua,easg.com
1,2,ua,zth.com
Read all entries in file1(which has 1000+) and compare column1 of file1 with the column4... (13 Replies)
Discussion started by: nuthalapati
13 Replies
3. UNIX for Advanced & Expert Users
File Structure
file1.txt.arch
029429288,1,,,02087400376,N,02087400376,N,0,02087400376,N,0,0,8010,08000151736,U,N,,08000151736,U,20100726111237,20100726111237,0,20100726111651,00004140,16,16,10,N;... (1 Reply)
Discussion started by: ravigupta2u
1 Replies
4. Shell Programming and Scripting
Hi,
I have two huge file; each one has approximately 150000 lines. I need to compare both of them and store the unmatched lines into a different file.
I have searched for everything in google but did not get solution.
Files are:
File1
NRALBAMINDB20003726
NRALBAMINDB20003727... (16 Replies)
Discussion started by: Suman Singh
16 Replies
5. Shell Programming and Scripting
Hi everybody (first time posting here)
I have a file1 that looks like >
1,101,0.1,0.1
1,26,0.1,0.1
1,3,0.1,0.1
1,97,0.5,0.5
1,98,8.1,0.218919
1,99,6.2,0.248
2,101,0.1,0.1
2,24,3.1,0.147619
2,25,23.5,0.559524
2,26,34,0.723404with 762 lines..
I have another 'similar' file2 >
... (10 Replies)
Discussion started by: murpholinox
10 Replies
6. Shell Programming and Scripting
Hi All,
I have two files in the following format.
File 1 :
1044|1|20121031|2910039.4|MR|201210|G1044|E
1082|2|20121031|1664662.84|MR|201210|G1082|E
1696|3|20121031|190801.5|MR|201210|G1696|E
1824|4|20121031|196350|MR|201210|G1824|E
1900|5|20121031|221447.8|MR|201210|G1900|E
File 2 :... (7 Replies)
Discussion started by: nua7
7 Replies
7. Shell Programming and Scripting
Hi ,
Im new to uxin environment and shell scripting....
please help me with the code for the following scenario.....
file 1 contains the following fields
abc 200 rupee IND
cdf 400 dollar USA
efg 300 euro GER
hij 600 pound ENG
file 2
SBI abc 321 dollar CANAD
kvr mnd ... (6 Replies)
Discussion started by: shivaji_veer
6 Replies
8. Shell Programming and Scripting
Dear all,
I am having two files big files i need an output file as first occurance of file1 field in file2
example:
file1:raju
ranifile2:raju|123
raju|879
rani|623
rani|253result:raju|123
rani|623pls help me in this regard (3 Replies)
Discussion started by: suryanarayana
3 Replies
9. Shell Programming and Scripting
Hi All,
I have a requirement to compare data column which is the last field in two different files and trigger and alert if the difference is greater than 1 for each row.
File1
Jan Acount1 2014 11223
Feb Account2 2014 2345
Mar Account3 2014 1233
File2
Jan Account1 2014... (1 Reply)
Discussion started by: Naresh Babu
1 Replies
10. UNIX for Beginners Questions & Answers
Hi,
Below are the sample files. x.txt is from an Excel file that is a list of users from Windows and y.txt is a list of database account.
$ head -500 x.txt y.txt
==> x.txt <==
TEST01 APP_USER_PROFILE
USER03 APP_USER_PROFILE
TEST02 APP_USER_EXP_PROFILE
TEST04 APP_USER_PROFILE
USER01 ... (3 Replies)
Discussion started by: newbie_01
3 Replies
LEARN ABOUT OPENDARWIN
join
JOIN(1) BSD General Commands Manual JOIN(1)
NAME
join -- relational database operator
SYNOPSIS
join [-a file_number | -v file_number] [-e string] [-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.
-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 either the form 'file_number.field', where file_number is a file number and field is a field number, or the form '0' (zero),
representing the join field. The elements of list must be either comma (``,'') or whitespace separated. (The latter requires quot-
ing 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.
DIAGNOSTICS
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.
-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_number.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 shellscripts don't require modification and should not be used.
STANDARDS
The join command conforms to IEEE Std 1003.1-2001 (``POSIX.1'').
SEE ALSO
awk(1), comm(1), paste(1), sort(1), uniq(1)
BSD
April 18, 2002 BSD