Finding the Big and Exact Match of Sample Data
Hi all,
I have data in two files and i need to find the exact and big match of values in file1 from that in file2 in new file3. file1 file2 file3(Required Results) 7890 8900 No output 7891 7890 7891 894 7909 No output 8058 89 8058 8059 792 8059 Kindly suggest any way for the resolution of the issue. Thanks |
Sounds good ... what have you attempted in an effort to solve the problem?
|
I have use nested loop and used awk.
while read file1 do while read file2 do awk -F \| '{if('$file2'~"'$file1'")print"$file2"}' smc >> match done<file2 done<file1 |
Quote:
Daniel B. Martin |
Quote:
Other example of big match 9 can be considered as big match for 999. 990 can be considered as big match for 99094 etc. |
Well you have lost me then :( I thought "big match" was your way of saying one number bigger than the other.
As it is not, would you please explain further as I am not seeing how any of your examples would explain your first example, for instance: Code:
8058 89 8058 |
Quote:
file1 file2 file3(Required Results) 7890 8900 No output 7891 7890 7891 894 7909 No output 8058 89 8058 8059 792 8059 |
Quote:
Please elaborate your criteria for matches and give more examples. Daniel B. Martin |
Quote:
More Examples 1 big match for 1234534 2345 big match for 23450000 990 is big match for 9903 |
Quote:
Code:
file1 file2 file3 Daniel B. Martin |
Quote:
|
Quote:
Daniel B. Martin |
Quote:
|
Quote:
Daniel B. Martin |
Still not clear to me so I will ask another question:
The format you have shown, ie file1 followed file2 and the output file3 has nothing to do with the lines being shown as they are? What we are saying is that for any match of file2 with a line in file1 will give "No output" (is this an empty line or actually these words?) whereas, if none of the items in file2 match the line in file1 then output the file1 value. Does that sound correct? |
Quote:
file1 file2 file3 8120 81 No output 8124 846 No output 8140 84259 No output 8308 1234 No output 8347 833 8347 84199 555 84199 84200 8308 No output 84228 842 No output 84249 8449 No output 84250 84200 No output 84258 8766 No output 84259 23456 No output 8435 98765 8435 8437 84240 8437 8449 789 No output 84588 7654 84588 84589 345 84589 |
Quote:
|
Quote:
|
Quote:
Daniel B. Martin |
Maybe something like:
Code:
awk 'FNR==NR{a[$1];next}{for(i in a)if($1 ~ "^"i){print;b=1;break}if(! b)print "no output";b=0}' file2 file1 > file3 |
Quote:
|
All times are GMT -5. The time now is 02:35 AM. |