1

This question already has an answer here:

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?

marked as duplicate by steeldriver, Mikel, Scott, jimmij, cas Apr 29 '16 at 6:21

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Shortest way may be \rm ... – Jeff Schaller 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 – steeldriver 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. – schily May 11 '16 at 10:23
1

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

\rm foo
"rm" foo

Further reading:

1

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. – schily 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. – schily May 11 '16 at 10:32

Not the answer you're looking for? Browse other questions tagged or ask your own question.