-1

I had an url for multiple projects inside i have multiple repos for each project I need to clone all the repos in a directory and find git branches.

i tried this

#!/bin/bash
project=(aa bb cc)
aa=(a b c)
bb=("d" "e")
cc=("g")
for i in "${project[@]}"
do
    echo "${!i}"
    for j in  @{$i}
    do
        echo $j
    done
done

But not getting the output .

  • Hello and welcome to U&L SE. As it stands your question is not very clear. Please edit it to include what output you actually expect. – Panki Mar 6 at 9:38
0

as I understood you want to iterate through arrays using dynamic arrays name. You can do it this way:

#!/bin/bash
project=(aa bb cc)
aa=(a b c)
bb=("d" "e")
cc=("g")
for i in "${project[@]}"
do
    var="$i[@]"
    for j in  ${!var}
    do
        echo j=$j
    done
done
  • but here i need to print all the values in project lists – Naik. Mar 6 at 9:54
  • this is exactly what you'll get – rush Mar 6 at 11:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.