Hi All.
Im currently attempting to write a script that takes the output of a command and put it into an array for me to 'play with' each item.
The problem I have is that it's currently treating the output as one item in the array as opposed to the nine items there actually is.
I run the command:
Code:
running=`su - zimbra -c "zmcontrol status"|grep Running| awk '{print $1}'|tr "\n" " "`
echo ${running[0]}
The command (starting from su -) returns a list of services. I attempt to format this into a space delmited list and pass this into a variable as an array.
However the entire list is becoming just one item in the array.
ie. the list is:
antispam antivirus ldap logger mailbox mta snmp spell stats
and echo ${running[0]} returns:
antispam antivirus ldap logger mailbox mta snmp spell stats
Any ideas what I'm doing wrong here?