Working with Bash Aliases (Alias/Unalias)

Bash - GNU Shell, Tips Add comments

Aliases allow a string to be substituted for a word when it is used as the first word of a simple command. The shell maintains a list of aliases that may be set and unset with the alias and unalias builtin commands.

You can set your aliases into your .bashrc file. Following some common aliases:

alias ls=’ls –color=auto’
alias dir=’ls –color=auto –format=vertical’
alias vdir=’ls –color=auto –format=long’
alias ll=’ls -l’
alias la=’ls -A’
alias l=’ls -CF’

All this is nice but how can you unset all this stuff ? Simple ! Use unalias builtin command.

# unset “ll” alias
unalias ll

# unset all aliases
unalias -a

Aliases are not expanded when shell isn’t interactive, unless the expand_aliases shell option is set using shopt.

shopt -s expand_aliases

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)
blog comments powered by Disqus
WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in