The command rm
nukes files.
rm -i
asks for confirmation before nuking the files.
When I use rm
, I want rm -i
to happen.
Ask Different is a question and answer site for power users of Apple hardware and software. It only takes a minute to sign up.
Sign up to join this communityThe alias command allows the user to launch any command or group of commands (including options and filenames) by entering a single word
alias rm="rm -i"
The next time you issue the command rm
it will issue rm -i
You can also make a new alias in case you want to keep rm
functioning as it does by default. To create a new alias
alias rmi="rm -i"
Now, rm
will have it's default behavior and rmi
will have the -i
option
To make it permanent, just add it to your ~/.bash_profile
. This way, everytime you open a new shell, your alias will be ready to go.
rm
by prepending rm
with a backward slash \rm
and it follows the default behavior.
rm
by prepending rm
with a \rm
and it follows the default behavior." is not accurate. To unalias an alias you use unalias name
, In a Terminal type help unalias
. Now if one has named an alias the same as a binary executable and one wants to run the binary executable instead of the same named alias, then one can stop alias expansion by prepending a `\` backslash and in doing so one is not unalias-ing the alias, the alias still exists.
Jul 10, 2016 at 13:34
help unalias
returns an error message in my shell.
unalias
is a bash shell built-in and in OS X the default shell, help unalias
returns: "unalias: unalias [-a] name [name ...] Remove NAMEs from the list of defined aliases. If the -a option is given, then remove all alias definitions." The key point here is using a "\" to stop alias expansion not unalias the alias, not even temporarily as it implies having to reset the alias. I know it somewhat antics with semantics however it's important to understand the difference between (temporarily) stoping alias expansion vs. unalias-ing the alias.
Jul 10, 2016 at 14:59
rm -i
, so he added it as an alias on every server. The upshot was that I and everyone else working with him developed a practice of runningrm -rf
when emptying a directory rather than the saferrm -r
, which will refuse to delete read-only files. You may think thatrm -i
makes you safer, but in my experience the opposite is the case.