In Bash there is an undo, but its not what you think
this thread is a little old... but just wanted to post a reply in case someone googles it
There will probably never be a command that will achieve what is desired above, as there is no way for bash to know what the equal and opposite of every single command is. For example, if you do a 'mkdir', bash will have to know that the opposite is 'rmdir'. Its not even the same command.
Having said that, there is a way to undo what you have done in bash itself.
pretend you want to 'chmod' a bunch of directories:
$> chmod 777 ./foo ./bar ./test ./yup
then you realize you want to 'chown' them instead. So you do a 'ctrl-a' to move to the front so you can replace 'chmod' with 'chown'
instead of doing an 'alt-d' to delete the word you accidentally do a 'ctrl-k' and delete the entire line!
so to "undo" what you just did on the command line, you do a 'ctrl-x, ctrl-u' to undo the last changes. 'Ctrl-_' does the same thing.
Voila, your line magically appears back in your terminal.
Last edited by iambrucelee; 02-19-2010 at 12:37 PM.