Monday, March 16, 2009

Temporarily disable an alias - bash shell

Listing the configured aliases on my box.

$ alias
alias mc='. /usr/share/mc/bin/'
alias rm='rm -i'

As you can see, rm is aliased as 'rm -i' (i.e. prompt before every removal)

So if you try to remove any file using 'rm', its going to prompt you for confirmation.

$ rm file.txt
rm: remove regular empty file `file.txt'? y

Now if you want the use 'rm' command without the alias additions (rm -i), you have two ways:

Way 1:
Unaliasing a command by simply prefixing the command with a \

$ \rm file.txt

Other alternative: Using unalias command

$ unalias rm

The above 'rm' one is just an example to illustrate this, (you can also do 'rm -f' for the same :-))

1 comment:

rattus said...

Another way to temporarily unalias is to use double quotes like in

$ "rm" file.txt

© Jadu Saikia