building a string

bash, ubuntu

Solution

If you want to append to a string, just

latex="$latex newstring"

or

latex=${latex}newstring

You need to be careful that bash doesn't interpret the above as a new var e.g. `"$a4`" would be interpreted as a variable `a4` and not as `$a` with `4` appended.

Problem

I have this code: ``` #!/bin/bash input="./user.cvs" while IFS=';' read -r f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 do path="./QRcodes/$f2$f3.png" vcard="BEGIN:VCARD%0AN;CHARSET=utf-8:$f3;$f2;;$f1;%0AADR;CHARSET=utf-8;INTL;PARCEL;WORK:;;$f10;$f11;;$f12;$f13%0AEMAIL;INTERNET:$f6%0AORG:$f4%0ATEL;WORK:$f8%0ATEL;FAX;WORK:$f9%0ATITLE:$f5%0AURL;WORK:$f7%0AEND:VCARD" latex="" encodedVCard=$(echo "$vcard" | sed -e 's/\+/\%2B/g') url="http://api.qrserver.com/v1/create-qr-code/?size=300x300&data=$encodedVCard" wget -O "$path" "$url" latex+="\n \\begin{tabular}{ C C } \\includegraphics[height=30mm]{graphic.png} & Name \\\\ \\end{tabular}" echo $latex done < "$input" ``` Everything works except the 'echo $latex' always prints the same line instead of multiple times. What am I missing?

Original source