1

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?

CJ7
  • 829

2 Answers2

1

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

\rm foo
"rm" foo

Further reading:

Thomas Dickey
  • 76,765
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).

cas
  • 78,579