i don't know where you prob is: you say that you know how to do it and that the only thing you need is to put echo " and "; around the code?
echo "echo \" $your_changed_code \"";
that's it.
the only thing you have to pay attention to is that you protect the quotes with a backslash