Hi Bigshots,
I have a pattern file with two columns. I have another data file. If column 1 in the pattern file appears as the 4th column in the data file, I need to replace it (4th column of data file) with column 2 of the pattern file. If the pattern is found in any other column, it should not be replaced.
Ex:
Pattern File:
opq,098
rst,765
xyz,321
Data File:
xyz,122,913,opq,876
rst,956,921,xyz,012
456,890,903,rst,467
Output File:
xyz,122,913,098,876
rst,956,921,321,012
456,890,903,765,467
Please note, first column of data file is not to be replaced.
I achieved this by looping the pattern file and doing awk line by line. But this is taking a lot of time. I want a faster script - shell script or PERL would do.
I saw corona688's reply in the thread titled "Replace column that matches specific pattern, with column data from another file".
However it is not addressing column specific search and replace requirement.