Thursday, March 3, 2011

BASH : Combine ARRAYS

#!/bin/sh

COUNTRY=( "Austria" "Finland" "USA")
CAPITAL=( "Viena" "Helsinky" "New York")

n=${#COUNTRY[@]} #num elements in array COUNTRY

for (( i=0; i<n; i++ ))
do
COMB[$i]=${COUNTRY[$i]}"["${CAPITAL[$i]}"]"
echo ${COMB[$i]}
done


ResultsAustria[Viena]
Finland[Helsinky]
USA[New York]

No comments:

Post a Comment