The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 07-16-2008
cytriesbash cytriesbash is offline
Registered User
  
 

Join Date: Jul 2008
Posts: 1
Array values treated as one

I want each integer to be a value/element in the array, however the string is being treated as one. How can I stream these into distinct values?

PSF6INDEX=`(snmpwalk -v 2c -c 'H0meru!es' ${SWITCH[3]} .1.3.6.1.2.1.2.2.1.2 | grep 'GigabitEthernet[3-9]' | sed 's/IF-MIB::ifDescr\.//g' | awk '{print $1}' | tr '\n' ' ')`

output is:

5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78


echo ${PSF6INDEX[0]}

output is:
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78