QUOTE(Tart @ 29-Apr-10, 14:28)
I learnt that on *nix systems with BASH after running "history" (usually piped through grep) to find that command you ran earlier and it displays the results along with an index, you can then just use "!xxx" where xxx is the index. and BASH will substitute the command.
You can also do (for example) "!/sbin" to invoke the last command that started /sbin.
# history | grep httpd
102 /sbin/service httpd stop
210 /sbin/service httpd start
230 vi /etc/httpd/conf.d/vhosts.conf
231 /sbin/service httpd restart
# # That was just to show what was in the history.
# !/sbin
/sbin/service httpd restart
Stopping Apache... [ OK ]
Starting Apache... [ OK ]
You need to be a bit careful with this, though, because you don't get any feedback before the command is executed - "!kill" is a bit like Russian roulette.
You can also do "!!" to just run the previous command again.
Another cool thing with bash is ` (backtick), which runs a command and then does text substitution of the result into your original command line, e.g. for FILE in `grep -l "Dan is bo"` ; do rm $FILE ; done, which deletes all files that contain "Dan is bo". (For this example, you could also do it via grep | xargs, which is more efficient and scalable but less flexible.)
Back to the original trail, yesterday I learnt that (according to a UN study) India has more mobile phones than toilets.
Matt