# How to override option in aliased command? [duplicate]

I have a rm aliased:

alias rm='rm -i'


How can I override the -i option when I want to remove a large number of files and I don't want to confirm each deletion?

• Shortest way may be \rm ... Apr 29 '16 at 1:22
• At least in the GNU coreutils implementation of rm, the -f flag overrides a previous -i flag; so you can simply add -f to the (aliased) command Apr 29 '16 at 1:41
• Unfortunately it turned out that this is not a duplicate of a previous question and the question is now blocked against a correct answer. May 11 '16 at 10:23

## 2 Answers

You can suppress the alias by escaping or quoting the command name, e.g.,

\rm foo
"rm" foo


Further reading:

With rm, -f overrides -i if it comes later on the command line.

Whichever option comes last on the command line will have effect, so you can override an alias rm='rm -i' just by using rm -f, which will expand to rm -i -f.

e.g.

$mkdir rmtest$ cd rmtest
$touch a b c d e f$ alias rm='rm -i'
$rm * rm: remove regular empty file 'a'? n rm: remove regular empty file 'b'? n rm: remove regular empty file 'c'? n rm: remove regular empty file 'd'? n rm: remove regular empty file 'e'? n rm: remove regular empty file 'f'? n$ rm -f *
$ls -l total 0$


rm -f -i will, of course, still prompt you for each file to be deleted.

(this is true for at least GNU rm. haven't tested with other versions).

• -f doesn't work on Solaris
– CJ7
Apr 29 '16 at 1:52
• -f works on Solaris as defined by the standard. Apr 29 '16 at 9:40
• @schily No it doesn't work. I have just tried it. It still asks for confirmation of the delete.
– CJ7
May 11 '16 at 0:22
• Answering your question would need a longer reply that may only be done in the "answer" form. This can only be done it the question is reopened. May 11 '16 at 10:32