Welcome to Centmin Mod Community
Become a Member

Sysadmin monitoring script question

Discussion in 'System Administration' started by hitman, Nov 12, 2016.

  1. hitman

    hitman Member

    110
    9
    18
    Jul 18, 2014
    Ratings:
    +13
    Local Time:
    12:57 AM
    hello, i am trying to make a script to automate some procedures and i am kind of stuck
    any help is much appreciated

    Code:
    for i in $my; do
        if[[ a condition here ]] ; then
            some variables here a,b,c
            i="0"
            arrayhere[i]="$a and $b variables are here and stored in the arrayhere array"
            i=$((i+1)) #increment i so next time variable will be stored in the next number
        fi
    done
    
    printf '%s\n' "${arrayhere[@]}"
    
    this is the logic and my problem is that the printf at the end only prints the last element of the array and not all the elements
     
  2. eva2000

    eva2000 Administrator Staff Member

    28,957
    6,574
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +9,756
    Local Time:
    7:57 AM
    Nginx 1.13.x
    MariaDB 5.5
    believe the printf is outside of the for loop that's why