Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

BASH-Array array

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

BASH-Array array

Array declaration: declare-an array actually does not need to declare, but assigns values to variables directly as an array. BASH will know that it is an array.

Array assignment:

You can also assign a value to the entire array: test= (var1 var2 var3... VarN)

Test= ([0] = var1 [1] = var2 [2] = var3... [n] = varN)

To assign values to an array, please refer to the definition of ordinary variables test [0] = var1.

Test [1] = var2

Test [2] = var3

Test [N] = varN-1

Array reference: ${test [subscript]}

For example:

$echo ${test [0]} var1

FYI. In addition, there are two special symbols, the * and @ signs, which refer to all array elements:

$echo ${test [*]} / * there are no spaces on both sides. This is indicated here because exblog recognizes errors.

Var1 var2 var3

# echo ${name [@]}

Var1 var2 var3

To display the number of elements in the entire array, use:

$echo ${# name [@]} 3

Referred Link:

Http://www.linuxfly.org/post/37/

Http://www.kklinux.com/html/biancheng/Shell/200905/02-5326.html

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.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report