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?
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)
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With