awk script required for finding records in 1 file with corresponding another file.
Hi,
I have a .txt file (uniqfields.txt) with 3 fields separated by " | " (pipe symbol). This file contains unique values with respect to all these 3 fields taken together. There are about 40,000 SORTED records (rows) in this file. Sample records are given below.
Now, there is another file (mainfile.txt) which contains 23 fields(columns), which contains the above fields as 7th, 13th and 14th field respectively. This file ie, mainfile.txt is also sorted and is seperated by pipe symbol. This file contains about 77,000 records. The 7th, 13th & 14th columns are from with in the above values only, but some records(rows) are repeated (with respect to these 3 fields(columns), other fields(columns) may or maynot be same.
What i need to do now is to compare first record (1st row) of uniqfields.txt with that of mainfile.txt and fetch first record (row) which contains all the above 3 fields same. That is, 1st field from uniqfields.txt should match with 7th column of mainfile.txt AND 2nd of uniqfields.txt with 13th of mainfile.txt AND 3rd of uniqfields.txt with 14th of mainfile.txt.
Why this is required with awk script..??
1) As i'm new to unix, i'm just catchin up wit awk and i'm not able to find a solution myself.
2) I tried with sort -t\| -u +6 -7 +12 -14 mainfile.txt > uniqmainfile.txt, but its working fine in SunOS and not working on NCR MP-RAS.
Actually, we are migrating these from server with SunOS to server with NCR MP-RAS. So, in SunOS, if i run the sort script just mentioned above, its fetching the first unique record, whereas in NCR MP-RAS its fetching the last unique record.
How does it impact if it takes last or first among from similar records..??
Actually, as we are checking for uniqueness only in the 7th, 13th and 14th fields(columns), the other fields(columns) are not matched with the reports in MP-RAS with that of SunOS.
I've tried with -r and tried using uniq command as well,but in vain. And found that the only solution is using awk.
I have three files named ALL, MATCH, and DIFF. Match and diff have completely different records included in the "all" file, but the "all" file also has records not in either the Match or Diff files.
I know I can sort all three files together, one unique and one without that option to show which... (5 Replies)
My Input file is fixed length record ends with . as end of the line and the character length is 4156
Example:
12234XYZ TY^4253$+00000-00000...........
I need to check is there any control characters(like ^M,^Z)
The line will be splitted
awk
'{id=substr($0,1,5)
nm=substr($0,6,3)... (2 Replies)
Not sure if this is the correct forum for this question. I have two files. file1.zip, file2
Input:
file1.zip
col1, col2 , col3
a , b , 0:0:0:0:0:c436:9346:d40b
x, y, 0:0:0:0:0:880:39f9:c9a7
m, n , 0:0:0:0:0:80c7:9161:fe00
file2.txt
col1
c4:36:93:46:d4:0b... (1 Reply)
Hi Friends,
I looking for the script for the count of the records in table.
and then it's containg the zero records then should get abort.
and should notify us through mail.
Can you please help me out in this area i am lacking. (5 Replies)
hi.. I want to compare records present in 1 file with those in 3 other files and print those records of file 1 which are not present in any of the files. for eg -
file1 file2 file3 file4
1 1 5 7
2 2 6 9
3
4
5
6
7
8
9
... (3 Replies)
I have 2 files
"File 1" is delimited by ";" and "File 2" is delimited by "|".
File 1 below (3 record shown):
Doc1;03/01/2012;New York;6 Main Street;Mr. Smith 1;Mr. Jones
Doc2;03/01/2012;Syracuse;876 Broadway;John Davis;Barbara Lull
Doc3;03/01/2012;Buffalo;779 Old Windy Road;Charles... (2 Replies)
Hello,
I have attached one file named file.txt .
I have to create a file using the awk script with the records in which 38th position is P and not V .
ex
it should have
00501 HOLTSVILLE NYP00501
and it should not include
00501 I R S SERVICE CENTER ... (3 Replies)
I want to filter records in one of my file using AWK command (or anyother command). I am using the below code
awk -F@ '$1=="0003"&&"$2==20100402" print {$0}' $INPUT > $OUTPUT
I want to pass the 0003 and 20100402 values through a variable. How can I do this?
Any help is much... (1 Reply)