全部博文(89)
分类: LINUX
2010-02-21 23:21:18
Aliases can be used only for the beginning of a command string—-albeit with certain exceptions. Sometimes you might want to define an alias for the directory name alone, not for the entire command. But if you define:
alias anim=sipp/demo/animation/voyager
and then type cd anim, bash will probably print a message like anim: No such file or directory.
An obscure feature of bash's alias facility—one not present in the analogous C shell feature—provides a way around this problem. If the value of an alias (the right side of the equal sign) ends in a blank, then bash tries to do alias substitution on the next word on the command line. To make the value of an alias end in a blank, you need to surround it with quotes.
Here is how you would use this capability to allow aliases for directory names, at least for use with the cd command. Just define:
alias cd='cd '
This causes bash to search for an alias for the directory name argument to cd, which in the previous example would enable it to expand the alias anim correctly.