I'm writing down a bash script which connects to my GPS router using SNMP command. I'm using "snmpwalk", this is the command :
snmpwalk -v 2c 10.0.0.250 -c public enterprises.30140.7.2
It returns back :
SNMPv2-SMI::enterprises.30140.7.2.0 = STRING: "3203.558467N"
Now my main target is to get the number "3203.558467" without the "N".
I'm new to Linux/bash and after a couple of searches I found that there is such thing called "eval", it helped me out and separated the whole string into an array and putted "3203.558467N" at the 4th cell (The code is at the end).
It's still not what I wanted since "N" is there.
I know that there are few more ways such as "sed" and "tr" but I don't know quite how to use them efficiently.
What is the best way to separate "3203.558467" in order to use this number for calculation?
#!/bin/bash
latitude=$(snmpwalk -v 2c 10.0.0.250 -c public enterprises.30140.7.2)
eval x=($latitude)
echo "latitude is : ${x[3]}"