Shell – way to undo a terminal command

command linefilesshell

I just copied a whole directory into another one using

cp ~/local/* ./

and actually wanted to type

cp ~/local/srl* ./

so I'm founding myself with a lot of unnecessary files. I can suppress them by hand but I was wondering, is there a way to undo ANY command on the term?

Best Answer

No, there is no way to undo a command(at least not universal). This is often a problem when users run rm with wrong regex, without realising that it covers more files than they would like to remove.

Also, it would really be impossible to implement undoing ANY command from terminal. Imagine command that sends an e-mail, or plays some sound. There is no way to undo these.

Just be happy that you ran cp, not rm.

As for the future, if you are not moving/removing/copying too many files, -i switch will turn it into "interactive" mode, asking for confirmation before each action.

Related Question