What I always do is type
rm -rf *
and then hit ESC-*, and bash will expand the * to an explicit list of files and directories in the current working directory.
The benefits are:
- I can review the list of files to delete before hitting ENTER.
- The command history will not contain "rm -rf *" with the wildcard intact, which might then be accidentally reused in the wrong place at the wrong time. Instead, the command history will have the actual file names in there.
- It has also become handy once or twice to answer "wait a second... which files did I just delete?". The file names are visible in the terminal scrollback buffer or the command history.
In fact, I like this so much that I've made it the default behavior for TAB with this line in .bashrc:
bind TAB:insert-completions