Linux shell array assignment method
In Bash, there are two ways to assign array variables:
(1) name = value1... Valuen) the subscript starts at 0 at this time
(2) name [index] = value
The following is illustrated by a simple script, which is as follows:
#! / bin/bash
# define an array
A = (a b c def)
# display the array as a string output
Echo ${A [@]}
# screen display: a b c def
# the length of the array represents ${# A [*]}
Len=$ {# A [*]}
Echo ${# A [*]}
# screen display: 4
# change the value of array elements
A [3] = 'vivian'
Echo ${A [*]}
# screen display: a b c vivian
# Loop output array elements
ITunes 0
While [$I-lt $len]
Do
Echo ${A [$I]}
Let iTunes +
Done
# screen output:
# a
# b
# c
# vivian
# another way to write the output array elements of the loop, note that in the condition, the reference variable must be in double quotes, otherwise an error will be reported
For ((jacu0; j)