Average of a column in console output
Hi guys,
I need to create a script in order to get the average jitter value of all asterisk call using "iax2 show netstat". Now using grep I receive the result as: Quote:
How is the best way for this? My return should be a Integer, for example: "2". Thanks! |
Code:
var=$(iax2 show netstat) |
Quote:
I have one doubt, what exactly does Quote:
Does it assign the output to the variable? And if it does, then the meaning of: Quote:
Thanks again! I googled for "set --" but did not found the answer... |
set -- [values] sets the $1..$2..$3...etc. positional parameters to those values. Note that this will overwrite any values that existed there before. See the builtin commands section of man bash for more.
$((..)) is the bash built in simple arithmetic function. Note that it only works with whole integers. You could also use an array to achieve the same effect. Code:
arr=( $(iax2 show netstat) ) |
Thanks David!
That demonstrate the power of bash! Thanks a lot, really! |
All times are GMT -5. The time now is 01:05 AM. |