I have the following bash code which loops through a text file, line by line .. im trying to prefix the work \'prefix\' to each line but instead am getting this error:
Instead of the for loop, it is more appropriate to use while read...:
while read...
while read -r line; do do echo "$line" | sed -e 's/^/prefix/' done < $file
But you would be much better off with the simpler:
sed -e 's/^/prefix/' $file