-1
#!/bin/bash

echo "Digite o IP"
read ip

iod= snmpwalk -v2c -c public "$ip":161 .1.3.6.1.2.1.1.5

echo "$iod"

OUTPUT

iso.3.6.1.2.1.1.5.0 = STRING: "Name"

I want just print the "name", I'm kinda new on bash scripting. I apreciate an hand. Thakyou.

STerliakov
  • 4,983
  • 3
  • 15
  • 37
LuizNFBR
  • 9
  • 3

1 Answers1

0

Use sed:

#!/bin/bash
echo "Digite o IP"
read ip
iod= snmpwalk -v2c -c public "$ip":161 .1.3.6.1.2.1.1.5
echo "$iod" | sed -e 's/^.*STRING: //'

This outputs just "Name" with the supplied data. We use sed to remove anything before the "STRING: " including the search string itself.

echo 'iso.3.6.1.2.1.1.5.0 = STRING: "Name"'  | sed -e 's/^.*STRING: //'
"Name"
James Risner
  • 5,451
  • 11
  • 25
  • 47