Welcome to the AndroidForums, Trogue!
Well, there are mime type file extensions (i.e., the files / programs associated with each file's extension suffix) that Android uses to associate things when you "reference" them (i.e., invoked in the proper context with the proper program).
You can see this with something like Astro File Manager (free in the Market) by going to menu -> More -> Preferences -> Edit File Extensions.
Now, what happens when you try to invoke/launch/run a particular file with its associated program I believe depends on whether or not you've installed a program that knows how to handle it (i.e., listens for system intents based on the given mime file type). You can see an example of this long-pressing a .txt file and seeing what programs show-up and are available to be launched with this .txt file type (its because the program has a compatible SEND mime type in its AndroidManifest.xml file).
In addition to the excellent example that Xyro mentioned, Gscript / Gscript Lite, there is also a similar program called Script Manager. These guys know how to invoke a sh shell program and feed the commands listed in a given script file to the sh shell and re-display the results to the Android window.
As far as launching things from a terminal emulator, well, that's just like a telnet client that you would see in Unix/Linux, so, all Unix-type rules apply (i.e., the #!<program path>-type references at the start of the script, etc.). The file must also be located in a non-SD card filesystem and its permission bits properly set if you are to execute it directly. Or, you'll have to invoke a shell (sh) and give it the name of the text file (.sh) containing your shell commands (i.e., "sh myscript.sh").
You best bet might be to create your files in a text editor on your PC, then invoke them with Gscript or Script Manager, or directly from a terminal window on your phone. You'll also have to be aware that you are pretty limited in what you can do without being rooted--many of the most useful commands are not present unless you have a busybox utility installed.
Cheers!