rm to prompt me when recursively deleting a directory, as in:
$ rm -r <dir> Do you want to remove the dir(Y/N)?
Is there an argument I can pass to
rm that will do this?
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.Sign up to join this community
Depending on what OS you're on, there's
rm -i (which will prompt for each individual file) or perhaps
rm -I (part of GNU rm), which, per the man page, will "prompt once before removing more than three files, or when removing recursively. Less intrusive than -i, while still giving protection against most mistakes"
I highly recommend against creating an alias for this, and instead build the habit of using one or the other of the above options. Being on a system without the alias you've gotten used to can create much grief (removing files you didn't intend to remove). Using the habitual option when you actually don't want it just means a minor annoyance (being prompted a few times, and either answering yes to each prompt, or breaking out (C-c) and starting again without the option). The latter is much less painful, I find.