rm | By default, the UNIX utilities rm, mv, and cp do what you tell them to without asking. If that means overwriting existing files or deleting all the files in the directory, they'll do it. If you want more safety, you can add aliases like these to your shell startup files (2.2): |
---|
C shell ksh, bash alias rm /bin/rm -i alias rm='/bin/rm -i' alias cp /bin/cp -i alias cp='/bin/cp -i' alias mv /bin/mv -i alias mv='/bin/mv -i'
(The pathname /bin/
may be different on your system.
You may be able to omit it completely, but watch out for alias loops if
you do.)
Then, when you type cp
or mv
at the command line,
the command will prompt you before destroying an existing file.
And the rm
command will always prompt you before every file
you ask it to remove (with a wildcard, this can take some time!).
These aliases set the -i (interactive) option; most versions of
cp, mv, and rm have it.
cp mv | The GNU versions of cp and mv have -i options. They also have an alternative: the -b option, which automatically makes a backup of any file that will be overwritten. |
---|
NOTE: These aliases can be dangerous when you don't have them. If you change to a new shell or use another account without these aliases, you can destroy files before you realize that the aliases aren't there to protect you. So, I don't use any of these aliases on my account. Instead, I check what I type before I press RETURN.
You can override the alias by typing:
%\rm *.o
C shells $command rm *.o
bash $/bin/rm *.o
Bourne shells
-