One of the most FAQ of all times.
Archive of posts tagged shell
Running local script remotely (with arguments)
Some ways to remotely run a local script.
“In-place” editing of files
Temporary files don't bite, so just use them.