Grep on output of command returns all output
I've used grep before but this makes me feel like a total noob. I can run "ls -l | grep install" and it will list only the file install.log. So when I try to run "noip2 -S | grep IP" why do I get the full output of the command and not just the line with the IP Address?
The stuff you see on the screen actually comes from *two* output streams: from both "stdout" (where "grep" expects to read from), and also from "stderr" (intended only for "error messages").
I'm guessing that your "noip2" either writes to stderr, or creates its own (third, separate!) output stream. Since grep only reads "stdout", you'd see *everything* from any stream that *isn't* "stdout".
'Hope that helps .. PSM
You can redirect different streams to a text file this way:
MYCMD > tmp.txt # redirects "stdout"
MYCMD 2> tmp.txt # redirects "stderr"
Great! Thanks! "noip2 -S 2>noip.txt" sent the output to the file noip.txt.
Also, a quick search on grep stderr showed how to redirect stderr to stdout
"noip2 -S 2>&1 | grep IP"
|All times are GMT -5. The time now is 09:17 PM.|