Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2012

    Question Unanswered: How to store actual mysql data in an array in shell script

    I am quite new in shell scripting and straight-away I am facing a problem. I want to query mysql database and store the result in an array in shell script. The query I am using is:

    result=`mysql -e "select SequenceID from wsnapp.apptrafficnew where DateTime between '2012-12-27 11:40:00' AND '2012-12-27 12:30:00';"`

    and I am also able store this data into an array by using:

    array=( $( for i in $result ; do echo $i ; done ) );

    but the problem is, it does not store the actual values. when I try to access the elements of array it shows something like that:


    here I am only storing integers(1,2,3,4...) in my database so my actual value stored is 1 not the SequenceID[1].

    I want to do some integer operations on the elements on array. So How do I store the actual values?

    Please help.

  2. #2
    Join Date
    Jun 2003
    West Palm Beach, FL



    array=( $result )

    The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts