Reputation: 14519
I'm doing a bash script and I'm grabbing the output from this command:
fpings=$(fping -c 1 -t 1 $ips | sort)
The fpings
variable does contain the output from the command, and the actual output of the command is not printed to the shell, but it still writes a line to the shell for each ip pinged.
There is a switch (-q
) to suppress the output (the part that I want) but not any to suppress the part I don't want.
How do I get the result from the fpings command without it printing stuff to the shell?
Upvotes: 10
Views: 9198
Reputation: 241848
If you do not want to see the standard error, redirect it to /dev/null
:
fpings=$(fping -c 1 -t 1 $ips 2>/dev/null | sort)
Upvotes: 11
Reputation: 18550
fpings=$( {fping -c 1 -t 1 $ips | sort; } 2>&1 )
should work the {} capture everything and then it redirects both streams (out and err) to just out and saves in the variable
Upvotes: 4