file1:
0000002|SLM DEV CORP |PO 857
0000003|S TOPPING |APT 19
0000004|JD BROS LTD |PO 118
0000005|ZKZ SERVICES |14699 CREDITVIEW RD
file2:
0000001|GTI CONSULTING |4513 GLADEBROOK CRES
0000002|SLM DEVELOPMENT CORP | SLM |PO BOX 857
0000003|S TOPPING |APT 19
0000004|JD PLETT BROS LTD |PO BOX 118
0000005|ZKZ SERVICES |ZKZ |14699 CREDITVIEW RD
expected output:
0000002|SLM DEVELOPMENT CORP | SLM |PO BOX 857
0000003|S TOPPING |APT 19
0000004|JD PLETT BROS LTD |PO BOX 118
0000005|ZKZ SERVICES |ZKZ |14699 CREDITVIEW RD
I have tried join command:
join -j1 1 -j2 1 -t'|' -o 1.1 2.2 2.3 file1 file2
Due to the pipe delimiter, I got wrong output. Also, I cannot use any other symbol as delimiter since any symbol can be available in column 2.
I need to match column 1 in file 2 and copy column 2 and 3 lengthwise.
I also tried looping column 1 data of file1 in file2 and getting the output but that takes too long since my files are very large.