LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1048|回复: 3

alias psl="ps axu | grep "怪事

[复制链接]
发表于 2005-9-28 16:30:37 | 显示全部楼层 |阅读模式
$alias psl="ps aux | grep " 或者alias psl="/bin/ps aux | /bin/grep " 这里grep和"间有空格
那么psl mplayer不成,但psl mplayerr,psl mplaye可以

但如果$alias pp="ps aux | grep"则没问题,这里grep和"间没有空格

>psl mplayer
grep:无效选项 -- t Usage: grep [OPTION]... PATTERN [FILE]... Try `grep --help' for more information.  

>psl mplayerr
eagle     7645  0.0  0.1   4716   640 pts/17   R+   16:21   0:00 grep mplayerr  

>psl mplaye
eagle    18964  0.0  0.8  29584  4200 ?        R    Sep27   0:00 mplayer -ontop -vo xv 马 一鸣-秋天的诉说.wmv
eagle    18971  0.0  0.9  29588  4764 ?        R    Sep27   0:00 mplayer -ontop -vo xv 马 一鸣-走在百姓行列里.rmvb
eagle     7620  0.0  0.1   4828   788 pts/17   R+   16:19   0:00 grep mplaye

系统为debian sid
 楼主| 发表于 2005-9-28 19:35:53 | 显示全部楼层
如果有空格,那么会对alias过的变量进行展开

发信人: wyk (freefantasy), 信区: Linux
标  题: Re: alias psl="ps axu | grep "怪事
发信站: 瀚海星云 (2005年09月28日19:26:16 星期三), 站内信件

在Learning the bash Shell, Second Edition上有这么一段话:

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 tr
ies to do alias substitution on the next word on the command line. To make t
he value of an alias end in a blank, you need to surround it with quotes.
回复 支持 反对

使用道具 举报

发表于 2005-9-28 20:26:24 | 显示全部楼层
在我的系统上正常哦, ????

  1. exnaba@Daydream:$ alias psl="ps aux | grep "
  2. exnaba@Daydream:$ psl fcitx
  3. exnaba    3772  0.0  2.6  16792 10380 ?        S    17:32   0:00 fcitx
  4. exnaba    3962  0.0  0.1   3896   748 pts/0    S+   20:20   0:00 grep fcitx
复制代码
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-9-29 08:22:04 | 显示全部楼层
我的mplayer是alias mplayer='mplayer -ontop -vo xv'过的
请仔细看看下面这些话:
如果有空格,那么会对alias过的变量进行展开

发信人: wyk (freefantasy), 信区: Linux
标 题: Re: alias psl="ps axu | grep "怪事
发信站: 瀚海星云 (2005年09月28日19:26:16 星期三), 站内信件

在Learning the bash Shell, Second Edition上有这么一段话:

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 tr
ies to do alias substitution on the next word on the command line. To make t
he value of an alias end in a blank, you need to surround it with quotes.
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表