Emacs: Run Shell in Emacs
Start Shell in Emacs
Alt+x shell
.
When in shell, to run the previous shell command, press Ctrl+↑.


Start a Second Shell in Emacs
Ctrl+u Alt+x shell
Call a shell command once
Alt+x shell-command
【Alt+!】
to run a single shell command.
Send text selection to a shell command
Select a region, then Alt+x shell-command-on-region
【Alt+|】.
For example, select a region, then type Alt+| wc -l Enter. This will print line count of region.
You can have the result replace the selected region.
To do that, do
universal-argument
【Ctrl+u】 before calling the shell on region command.
My shell doesn't work in Windows?
Most problems are probably caused by incorrect environment variable setup. See: Emacs in Microsoft Windows FAQ.