I am running the following command:
[user@server ~]$ /usr/sbin/ntpdate -d IPREMOVEDFORSECURITY | egrep 'transmit timestamp' | tail -1 | awk '{print $4, $5, $6, $7, $8}'
host found : HOSTREMOVEDFORSECURITY
Tue, Feb 15 2011 12:38:38.321
So the issue is, I always get the "host found :" line no matter which type of redirect I use. I have tried the following:
0>/dev/null
1>/dev/null
2>/dev/null
2>&1
2>&/dev/null
And every other variation I can think of, or have been able to find online. All I need and want to be returned is the second line (timestamp) of that command output. I don't understand why I can't seem to affect the "host found:" line?!?!
I'm running these commands through perl, however I see the same behavior when running them directly in bash. I need to suppress that host: line because in perl, I'm running the command using backticks to assign the output to a variable, and output a clean response based on some other conditionals. No matter what, that host line shows and muddies up my script's output, though it doesn't affect what is actually assigned to the variable.
My assumption here is that this line is not using the normal STDIN, STDOUT, STDERR threads, but I can't seem to pin down any specific information on a 4th output method. Every site I've found yet only talks about those three.
If anyone has the answer to this, please please please let me know!
PS: this isn't the only command that shows this behavior, chkconfig and some others also do this, and I'd really like to figure out how to suppress this unnecessary output.