I've a CSV file with multiple rows. I wanted to copy the same data multiple times and each time replacing a specific character with another character from a different file.
Example:
Below are two files, a csv and a ref file (containing A to Z) characters. I wanted to copy the csv content 26 times (A to Z) and each time replacing the variable VAR with A,B,C,....Z.
cat csv_file
some text with VAR,data 2,data 3,data 4,some text and VAR
,,,data 4,some text
,,,data 4,some text
cat ref
A
B
C
...so on upto
Z
Result:
some text with A,data 2,data 3,data 4,some text and A
,,,data 4,some text
,,,data 4,some text
some text with B,data 2,data 3,data 4,some text and B
,,,data 4,some text
,,,data 4,some text
..
... so on
what I'm doing is
DATA="some text with & following text,data 2,data 3,data4,some text and_&\n,,,data4,some text\n,,,data 4,some text"
sed -e "s/^.*$/$DATA/g" ref
Is there any other way of achieving the same result but with file name instead of variable (DATA)?