I have a csv file like this.
aaa|c1|bbb|t1
bbb|c1,c2|nnn|t1,t2
The pipe is the delimiter. I want to generate a string with columns 2 and 4. And I need to add a prefix for both column values.
Column 2 = a is the prefix
column 4 = b is the prefix
Expected output:
this is final string a.c1=b.t1
this is final string a.c1,a.c2=-b.t1,b,t2
My sample script (in complete):
while read r_line
do
c2 = $(echo $r_line|awk -F'|' '{print $2}')
c4 = $(echo $r_file |awk -F'|' '{print $4}')
out=$("this is final string a.$c2=b.$c4")
done < csv file
Here if the c2 or t2 has comma-separated values I need to apply the prefix for both the values.