Sample Header Ad - 728x90

For loop through a variable vector

2 votes
2 answers
624 views
I have a for loop and case statements. The for loop has quite a bit element list and the case statement will assign an 1D array or a vector. These values will be used in for loop after. I have the following code. What happens is that the for loop does the job only for the first value in the vector. For example, if the f=C, the case is "C") isotope=(6012 6013);; for n in $isotope: It loops only for 6012 not for 6013. Same issue with f=Ce, it only does the loop for 58136 not for the rest. # loop through elements for f in C Ce do cd ${f} case $f in "Al") isotope=(13027) ;; "C") isotope=(6012 6013);; "Ce") isotope=(58136 58138 58140 58142);; esac for n in $isotope do ....# loop through elements for f in C Ce do cd ${f} case $f in "Al") isotope=(13027) ;; "C") isotope=(6012 6013);; "Ce") isotope=(58136 58138 58140 58142);; esac for n in $isotope do .... Thank you for the help Birsen
Asked by BircanA (21 rep)
May 2, 2023, 05:59 PM
Last activity: May 3, 2023, 03:24 PM