6

I know there is a simple syntax for telling bash not to expand aliases. However, Google is not turning it up and I'm too lazy to read through man bash. Also, the answer should be on this website.

12

Put a backslash before the first character.

$ alias ls="echo foo"
$ ls
foo
$ \ls
bin
Desktop
Documents
  ...
  • 4
    By the way, this is not a bash-specific feature. It's mandated by POSIX, and works in bash, ksh and zsh amongst others. – Gilles Oct 16 '10 at 11:40
8

You can use command shell builtin command. It will execute only commands found in the PATH or shell builtins. It won't execute aliases or shell functions.

Example:

alias ls='ls -l'
$ ls
drwxr-xr-x 3 user user 4096 2010-10-11 13:17 dir1
drwxr-xr-x 3 user user 4096 2010-10-15 15:37 dir2
$ function ls() {
> echo hello
> }
$ ls
hello
$ command ls
dir1  dir2
3

Type shopt -u expand_aliases into the bash shell (the -u switch is for unset). I recommend reading the man page for shopt.

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

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