linux - How can I combine a variable name when export a new variable? -


say have loop:

for z in {0..11} export jbod$z=`grep "firmware state" driveinfo-$z | awk 'begin{fs=":";} {print $2}'` done 

how can new variable i'm trying export include number loop? each pass of loop want variable so: jbod1=string jbod2=string jbod3=string

i should mention if echo $jbod$z doesn't work...

thanks!

your code setting variables works. you're reading value incorrectly.

try echo $jbod4 , you'll see they're set.

to access variables dynamically, can use indirection:

z=4 name="jbod$z" echo "$name set ${!name}" 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -

django - CSRF verification failed. Request aborted. CSRF cookie not set -