I'm learning the shell, and I want to be able to loop over some variables. I can't seem to find anywhere where anyone has done this so I'm not sure it's even possible.
Basically I just want to save myself trouble by using the same sed command on each of these variables. However the code obviously doesn't work. My question is, is it possible to loop over variables and if not how should I be doing this?
title="$(echo string1)" artist="$(echo string2)" album="$(echo string3)" for arg in title artist album do $arg="$(echo "$arg" | sed -e 's/&/\&/g' -e 's/</\</g' -e 's/>/\>/g')" done here is the error:
line 12: syntax error near unexpected token `$arg="$(echo "$arg" | sed -e 's/&/\&/g' -e 's/</\</g' -e 's/>/\>/g')"'