3

我想为| grep

例如,例如能够写:

ps -axf G chrome代替ps -axf | grep chrome

我在 oh-my-zsh 的别名文件中写了以下内容:

alias -g G= '| grep --color'

但是,这似乎不起作用。

知道为什么吗?

编辑

我写的时候出现以下错误ps -axf G chrome

error: must set personality to get -x option

Usage:
 ps [options]

 Try 'ps --help <simple|list|output|threads|misc|all>'
  or 'ps --help <s|l|o|t|m|a>'
 for additional help text.

For more details see ps(1).

似乎G被解释为 ps 命令的一部分

4

2 回答 2

2

我有

alias -g G=' | grep -i '

所以语法似乎没问题

所以我可以这样做:-

cat file.txt G fred

你真的在运行 zsh (echo $SHELL)

于 2014-07-16T08:48:31.703 回答
1

您的alias语句在分配之间不能有空格:

alias -g G='| grep --color'
于 2014-07-16T08:52:58.767 回答