Trying to match $2 in original_targets with $2 of new_targets should be written to match.txt. If the two numbers match exactly then a match.txt file is outputted using the information in the new_targets in the beginning 4 fields $1, $2, $3, $4 and value of $4 in the original_targets . If there is "No Match" then a no match file is created using the information in the original_targets $1,$2,$3,$4 Thank you .
So for example,
the first $2 in original_targets is 34529 and that value does not match exactly $2 of new_targets, so that is copied to a "No Match file" as
the 150 $2 in original_targets is 1114780 and that values matches row 251201 exactly so is copied to a match.txt as
I'm very confused.
Your description says that, for matched lines, output consisting of fields 1-4 of new_targets.txt and field 4 from the matched original_targets.txt line. Your example says the matched line is written unchanged. The sample code changes one or more spaces between fields to a single tab and keeps all input fields no matter how many fields are present in the input.
Your description says that fields 1-4 from unmatched lines are written to a different file. You sample code changes field 2 to the string "No Match" and changes every other sequence of one or more spaces in an input line to a tab (keeping all input fields no matter how many are present) and writes them to the same output file as the matched lines.
Your example says that there are 150 matches for field 2 containing 1114780 in original_targets (without .txt), so line 215201 from one of the files (which file is not specified) is to be copied to match.txt without adding field #4 from any of the 150 matching lines from original_targets.txt.
Please rewrite your requirements clearly, provide (small) samples of the two input files, and a corresponding sample output file that should be produced from those sample input files.
This User Gave Thanks to Don Cragun For This Post:
Hi,
How to check if a string on file2 exactly matches with a part or complete string on file1, and return a match indicator based on some match rules.
1) only records on file1 with category A should be matched. for other category, the output match indicator should default to 'N'
2) on file2... (13 Replies)
In folder there are files
(eg ABS_18APR2012_XYZ.csv
DSE_17APR2012_ABE.csv) .
My requirement is to delete all the files except today's timestamp
I tried doing this to list all the files not having today's date timestamp
#!/bin/ksh
DATE=`date +"%d%h%Y"`
DIR=/data/rfs/... (9 Replies)
I am trying to look for $2 of file1 (skipping the header) in $2 of file2 (skipping the header) and if they match and the value in $10 is > 30 and $11 is > 49, then print the line from file1 to a output file. If no match is foung the line is not printed. Both the input and output are tab-delimited.... (3 Replies)
I am trying to create a cronjob that will run on startup that will look at a list.txt file to see if there is a later version of a database using database.txt as the source. The matching lines are written to output.
$1 in database.txt will be in list.txt as a partial match. $2 of database.txt... (2 Replies)
Hi All,
I need some help trying to achieve the below but everything I've tried has failed, I have 2 files which i'm trying to carry out a match based on the first column from file 1, take that value find it in file 2 if found replace it with the second column from File 1
Lookup File: File 1... (3 Replies)
I thought I had this figured out but was wrong so am humbly asking for help.
The task is to add an additional column to FILE 1 based on records in FILE 2.
The key is in COLUMN 1 for FILE 1 and in COLUMN 1 OR COLUMN 2 for FILE 2.
I want to add the third column from FILE 2 to the beginning of... (8 Replies)
Hello all, First post here. I did not notice a previous post to help me down the right path. I am looking to compare a column in a CSV file against another file (which is not a column match one for one) but more or less when a match is made, I would like to append a third column that contains a... (17 Replies)
Hi,
i have 2 files , the data i need to match is in masterfile and i need to pull out column 3 from master if column 1 and 2 match and output entire row to new file
I have tried with join and awk and i keep getting blank outputs or same file
is there an easier way than what i am... (4 Replies)