我使用此命令来获取 apache 服务器版本:
apachectl -V | grep -i“服务器版本”| tr“/”“” | awk '{ print $4 }'
但这并不适用于所有系统。有时我会在服务器版本输出之前得到一些其他输出。
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message
问题是为什么我会得到这个输出,即使 grep 应该将其过滤掉?我知道我可以抑制它,但为什么即使我使用 grep 它仍然显示?
最佳答案
该消息可能会发送到标准错误,而不是标准输出。要隐藏它,请将 stderr 重定向到任何地方:
apachectl -V 2>/dev/null | grep ...
关于linux - 使用命令行工具获取apache服务器版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35085506/