Issue
I use this command to get the apache server version:
apachectl -V | grep -i "Server version" | tr "/" " " | awk '{ print $4 }'
But this does not work on every system. Sometimes i get some other output before my server version output.
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
The question is why do i get this output, even though grep should filter it off? I know that i can suppress it, but why does it even show even though i use grep?
Solution
The message probably goes to the standard error, not standard output. To hide it, redirect stderr to nowhere:
apachectl -V 2>/dev/null | grep ...
Answered By - choroba