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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 13:41:52  来源:igfitidea点击:

CentOS: bash: grep: command not found

bashcentos

提问by zinon

I have CentOS release 6.3

我有 CentOS 6.3 版

I'm trying to use grepin 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

  1. Locate your grep installation path. Most likely it's either /bin/grepor /usr/bin/grep.
  2. 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.
  1. 找到您的 grep 安装路径。很可能是/bin/grep/usr/bin/grep
  2. 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 目录添加到系统路径变量。