And in fact whenever you want to do some command like:
cmd some_flags_and_args_and_metacharacters ...
you can just replace cmd with echo first to see what that full command will expand to, before you actually run it, so you know you will get the result you want (or not). This works because the $foo and its many variants and other metacharacters are all expanded by the shell, not by the individual commands. However watch out for > file and >> file which will overwrite or append to the given file with the output of the echo command.
http://www.terminalinflection.com/negotiating-a-damaged-linux-filesystem-using-only-shell-builtins/
http://eusebeia.dyndns.org/bashcp
https://news.ycombinator.com/item?id=1212051Was not really an issue for me personally, since it was not on my machine. Used to encounter such situations with some regularity when I was a Unix (and general) system engineer in the field, for a large hardware + Unix vendor, early in my career. The job involved solving all sorts of software problems (sometimes involving many levels of the stack) for customers of my employer. Sometimes, less technically savvy customers, like data entry operators or end users of the Unix systems sold by that vendor to them, would end up doing things like that - deleting critical files, losing backups or not taking backups and then the hard disk or OS crashed, corrupting the data on disk, etc. Got to handle many and diverse interesting problems in this area, and learned a lot from it; some of those skills have served me in good stead later in my career too - troubleshooting, Unix fundamentals and skills, interaction of apps with the OS, etc.
As sethrin says, you don't have to acquire the scars personally. And thanks, sethrin, for those links - should make for some good reading, I'm interested in this area though I do not work on it from some time. It can be good fun and mental exercises in problem solving.
So typing 'rm foo* ' and pressing Alt-? (on non-OSX computers) will give you a list of what your wildcard would expand to.
M-* does the same thing but actually expands the wildcards, instead of just showing what that expansion would be.