我在 .zshrc 中有一个函数(shell 是 zsh)。
test1(){
toprint=$(ps -ef | grep $1)
echo $toprint
}
这给出了以下输出。 asiri ~ test1 gradle
grep: gradle: No such file or directory
经过一番研究,我发现语法高亮插件添加了一个别名zsh -x 2>zsh.trace
exit
grep 'alias.*grep' zsh.trace
#part of output
+/home/asiri/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh:593> eval $'.... long string here..
+(eval):132> alias 'grep=grep --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn,.idea,.tox}'
由于它是作为脚本的一部分添加的,因此我无法将其注释掉。但是如果没有这样的别名集(我的另一个 linux vm 之一),上面的函数可以正常工作。
请告知是否有解决此问题的方法。
我也尝试了“unalias”,将其添加到 .zshrc 文件中。它也没有解决问题。
谢谢!
最佳答案
使用 grep 的完整路径:/usr/bin/grep
关于linux - 在 .zshrc : No such file or directory 中使用 grep 命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67489468/