shellmatrixdata-masking

Unmask data from matrix linux shell


i have 2 file.

analizeddata.txt:

A001->A002->A003->A004
A001->A005->A007
A022->A033
[...]

and

matrix.txt:

A001|Scott
A002|Bob
A003|Mark
A004|Jane
A005|Elion
A007|Brooke
A022|Meggie
A023|Tif
[..]

How i can replace in analizeddata.txt, or obtain a new file, with the second column of matrix.txt? The expected output file will be as:

Scott->Bob->Mark->Jane
Scott->Elion->Brooke
Meggie->Tif
[...]

Thanks


Solution

  • Just use sed to replace the string what you want.

    for replace_mode in $(sed 's/|/\//g' matrix.txt); do sed -i 's/'$replace_mode'/g' analizeddata.txt; done