Friday, October 9, 2009

Linux - Bash Shell Scripting - Aliases

An alias is another name for something. In Bash, you can define aliases for commands using the syntax alias name=command. In this example, assume rmwild is a user-created program,

$ alias rmwild="./rmwild"
$ rmwild tmp *.o
$ alias gohome=cd ~
$ pwd
/usr/bin
$ gohome
$ pwd
/home/fredf

Aliases defined on the command line only exist for the current Bash session. If you want the alias name to be available every time you log in, define the alias in your .bashrc file. To delete an alias that was defined at the command prompt, use the unalias command, e.g., unalias rmwild. To delete all of your aliases, type unalias -a.

Previous - Command Line Arguments | Next - Displaying Text from Shell Script

No comments:

Post a Comment