Skip to main content
grammar
Source Link
ctrl-alt-delor
  • 28.8k
  • 11
  • 66
  • 113

weI set inan array disksnamed “disks” to the following words - sdb sdc sdd

from linuxin bash shell:

bash declare -A disks Machines=worker01Machine=worker01 disks[$Machines]="sdbdisks[$Machine]="sdb sdc sdd" 

now we print all words as the following:

echo ${disks[@]} sdb sdc sdd 

now we want to print the first arrayitem ( that should be sdb )

echo ${disks[0]} 

but no output

the same aboutwith:

echo ${disks[1]} echo ${disks[2]} 

also aboutwith:

echo ${disks[3]} echo ${disks[4]} 

. . .

what is wrong here?

also not as:

for i in {1..100} > do > echo ${disks[$i]} > done 

so how tocan I print the first words fromof the array disks“disks” - when Machines=worker01Machine=worker01

echo ${disks[$Machines]disks[$Machine]} 

we set in array disks the following words - sdb sdc sdd

from linux shell:

bash declare -A disks Machines=worker01 disks[$Machines]="sdb sdc sdd" 

now we print all words as the following:

echo ${disks[@]} sdb sdc sdd 

now we want to print the first array ( that should be sdb )

echo ${disks[0]} 

but no output

the same about:

echo ${disks[1]} echo ${disks[2]} 

also about:

echo ${disks[3]} echo ${disks[4]} 

. . .

what is wrong here?

also not as:

for i in {1..100} > do > echo ${disks[$i]} > done 

so how to print the first words from array disks - when Machines=worker01

echo ${disks[$Machines]} 

I set an array named “disks” to the following words - sdb sdc sdd

in bash shell:

declare -A disks Machine=worker01 disks[$Machine]="sdb sdc sdd" 

now we print all words as the following:

echo ${disks[@]} sdb sdc sdd 

now we want to print the first item ( that should be sdb )

echo ${disks[0]} 

but no output

the same with:

echo ${disks[1]} echo ${disks[2]} 

also with:

echo ${disks[3]} echo ${disks[4]} 

what is wrong here?

also not as:

for i in {1..100} > do > echo ${disks[$i]} > done 

so how can I print the first words of the array “disks” - when Machine=worker01

echo ${disks[$Machine]} 
added 107 characters in body
Source Link
yael
  • 14k
  • 72
  • 221
  • 377

we set in array disks the following words - sdb sdc sdd

from linux shell:

bash declare -A disks Machines=worker01 disks[$Machines]="sdb sdc sdd" 

now we print all words as the following:

echo ${disks[@]} sdb sdc sdd 

now we want to print the first array ( that should be sdb )

echo ${disks[0]} 

but no output

the same about:

echo ${disks[1]} echo ${disks[2]} 

also about:

echo ${disks[3]} echo ${disks[4]} 

. . .

what is wrong here?

also not as:

for i in {1..100} > do > echo ${disks[$i]} > done 

so how to print the first words from array disks - when Machines=worker01

echo ${disks[$Machines]} 

we set in array disks the following words - sdb sdc sdd

from linux shell:

bash declare -A disks Machines=worker01 disks[$Machines]="sdb sdc sdd" 

now we print all words as the following:

echo ${disks[@]} sdb sdc sdd 

now we want to print the first array ( that should be sdb )

echo ${disks[0]} 

but no output

the same about:

echo ${disks[1]} echo ${disks[2]} 

also about:

echo ${disks[3]} echo ${disks[4]} 

. . .

what is wrong here?

also not as:

for i in {1..100} > do > echo ${disks[$i]} > done 

we set in array disks the following words - sdb sdc sdd

from linux shell:

bash declare -A disks Machines=worker01 disks[$Machines]="sdb sdc sdd" 

now we print all words as the following:

echo ${disks[@]} sdb sdc sdd 

now we want to print the first array ( that should be sdb )

echo ${disks[0]} 

but no output

the same about:

echo ${disks[1]} echo ${disks[2]} 

also about:

echo ${disks[3]} echo ${disks[4]} 

. . .

what is wrong here?

also not as:

for i in {1..100} > do > echo ${disks[$i]} > done 

so how to print the first words from array disks - when Machines=worker01

echo ${disks[$Machines]} 
added 23 characters in body
Source Link
yael
  • 14k
  • 72
  • 221
  • 377

we set in array disks the following words - sdb sdc sdd

from linux shell:

bash declare -A disks Machines=worker01 disks[$Machines]="sdb sdc sdd" 

now we print all words as the following:

echo ${disks[@]} sdb sdc sdd 

now we want to print the first array ( that should be sdb )

echo ${disks[0]} 

but no output

the same about:

echo ${disks[1]} echo ${disks[2]} 

also about:

echo ${disks[3]} echo ${disks[4]} 

. . .

what is wrong here?

also not as:

for i in {1..100} > do > echo ${disks[$i]} > done 

we set in array disks the following words - sdb sdc sdd

from linux shell:

bash declare -A disks Machines=worker01 disks[$Machines]="sdb sdc sdd" 

now we print all words as the following:

echo ${disks[@]} sdb sdc sdd 

now we want to print the first array

echo ${disks[0]} 

but no output

the same about:

echo ${disks[1]} echo ${disks[2]} 

also about:

echo ${disks[3]} echo ${disks[4]} 

. . .

what is wrong here?

we set in array disks the following words - sdb sdc sdd

from linux shell:

bash declare -A disks Machines=worker01 disks[$Machines]="sdb sdc sdd" 

now we print all words as the following:

echo ${disks[@]} sdb sdc sdd 

now we want to print the first array ( that should be sdb )

echo ${disks[0]} 

but no output

the same about:

echo ${disks[1]} echo ${disks[2]} 

also about:

echo ${disks[3]} echo ${disks[4]} 

. . .

what is wrong here?

also not as:

for i in {1..100} > do > echo ${disks[$i]} > done 
Source Link
yael
  • 14k
  • 72
  • 221
  • 377
Loading