Chinaunix首页 | 论坛 | 博客
  • 博客访问: 543613
  • 博文数量: 92
  • 博客积分: 2511
  • 博客等级: 少校
  • 技术积分: 932
  • 用 户 组: 普通用户
  • 注册时间: 2008-10-19 10:10
文章分类
文章存档

2011年(6)

2010年(27)

2009年(37)

2008年(22)

我的朋友

分类: 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.

阅读(712) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~