Thursday, March 3, 2011

BASH : Pass arrays as argument

#!/bin/bash


array1=(1 2 3 4 5 6 7 8 9)
array2=(10 20 30 40 50 60 70 80 90)


printArrays()
{
    declare -a argAry1=("${!1}")
    echo "${argAry1[@]}"


    declare -a argAry2=("${!2}")
    echo "${argAry2[@]}"
}


printArrays array1[@] array2[@]

No comments:

Post a Comment