CentOS:bash:grep:找不到命令
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33015404/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
CentOS: bash: grep: command not found
提问by zinon
I have CentOS release 6.3
我有 CentOS 6.3 版
I'm trying to use grep
in a script and I get bash: grep: command not found
.
我正在尝试grep
在脚本中使用,但我得到bash: grep: command not found
.
Any ideas how to fix this?
任何想法如何解决这一问题?
A few months ago it was working properly.
几个月前,它运行正常。
采纳答案by Zloj
- Locate your grep installation path. Most likely it's either
/bin/grep
or/usr/bin/grep
. echo "export PATH=$PATH:/<path_to_grep>" >> ~/.bash_profile
. Note that ~/.bash_profile here means your bash startup file. The one that gets sourced on bash shell startup.
- 找到您的 grep 安装路径。很可能是
/bin/grep
或/usr/bin/grep
。 echo "export PATH=$PATH:/<path_to_grep>" >> ~/.bash_profile
. 请注意,这里的 ~/.bash_profile 表示您的 bash 启动文件。在 bash shell 启动时获取的那个。
In case if you do not have grep for whatever reason or you just can't find / -iname "*grep*"
- you can download and install it: gnu FTP. Any other reliable source is fine too. Then use steps 1 and 2 to add your grep directory to system path variable.
如果由于某种原因您没有 grep 或者您无法find / -iname "*grep*"
安装 - 您可以下载并安装它:gnu FTP。任何其他可靠的来源也很好。然后使用步骤 1 和 2 将您的 grep 目录添加到系统路径变量。