In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Array definition in shell:
You can define the array as a whole:
ARRAY_NAME= (value0 value1 value2 value3...)
Or:
ARRAY_NAME= (value0value1value2value3...)
At this point, the subscript of the array starts at 0 by default, and each component of the array can be defined separately:
ARRAY_NAME [0] = value0ARRAY_NAME [1] = value1ARRAY_ name [n] = valuen...
There can be no use of consecutive subscripts, and there is no limit to the range of subscripts.
Get the elements in the array:
Valuen=$ {ARRAY_ NAME[n]}
All the elements in the array are worth it at once:
Echo ${ARRAY_NAME [@]}
Get the number of elements in the array:
Length=$ {# ARRAY_NAME [@]} or length=$ {# ARRAY_NAME [*]}
Gets the length of a single element of the array:
Lengthn=$ {# ARRAY_ NAME[n]}
Array traversal:
Use while to loop through the array:
While [$I-lt $length]; dovaluei=$ {ARRAY_NAME [$]}. Let i++done
Use for to loop through the array:
For value in ${ARRAY_NAME [*]}; dovaluei=value...done
Empty the array:
Empty a single element:
ARRAY_ name [n] =
Empty the entire array:
Unset ARRAY_NAME or: ARRAY_NAME=
It should be noted that variables after unset should not add $. Adding $clears the variable with the value of ARRAY_NAME.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.