how to format the output of a command and save it into a string variable
Hi guys,
I have a script that would return the cpu load of a machine. I want to get the numerical part of the output, but I do not know how to do it. <code snippet> result="$(snmpget -v 2c -c public localhost -Ov .1.3.6.1.4.1.2021.11.11.0)" if [${result##INTEGER: }=95]; then echo $result fi </code snippet> When I execute the command, I get "./montop.sh: line 13: [95=95]: command not found" error. How do I solve this problem? TIA. edited: I got the wrong part already. It was in my if statement.. :) |
well for clarity the [ is actually a command alias for test. just like you can't run "cd/my/directory" you can't run "[1=0]" due to whitespace issues, it.d be "[ 1 = 0 ]"
|
All times are GMT -5. The time now is 03:39 AM. |