« Guarded Commands | Main | Red Hot Pawn »

\command

The \ character performs multiple functions in Unix shells. One less known use is to bypass shell aliases. For example, I use srm(1) by default, and revert to the insecure (yet much faster) rm(1) for large files that do not require secure deletion (install packages, in particular).

$ alias rm rm='srm -s -z'

Practice with echo(1) to get a feel for \command behavior.

$ echo test test $ alias echo='echo foo' $ echo test foo test $ \echo test test $ unalias echo

However, nothing stops \command from being an alias itself:

$ alias echo='echo foo' $ alias \\echo='echo bar' $ echo test foo test $ \echo test foo bar test $ \\echo test zsh: command not found: \echo

You can also create a \echo command, and so forth:

$ chmod +x ~/bin/\\echo $ cat ~/bin/\\echo exec echo $@ $ \\echo test test

Technorati Tags: