filmov
tv
Arrays In LINUX | Array in shell scripting tutorial | Arrays i | How to Define Array in UNIX
![preview_player](https://i.ytimg.com/vi/yPPjtot_ceM/maxresdefault.jpg)
Показать описание
This video explains about the Unix Array variable and how its very handy to use . Also it covers the benefits of using arrays in use cases instead any temporary file.
ARRAYS (DEFINE & ACCESS) IN SHELL SCRIPTING || LINUX || UNIX || ARRAY INITIALIZATION AND ACCESSING
An array is a variable containing multiple values. Any variable may be used as an array. There is no maximum limit to the size of an array, nor any requirement that member variables be indexed or assigned contiguously. Arrays are zero-based: the first element is indexed with the number 0.
Define Array
1) array_name[index]=val1
array_name[index]=val2
- - - - -
2) array_name=(val1 val2 val3 .........)
3) array_name=([index]=val1 [index]=val2 [index]=val3 . . . . .)
Access Elements of Arrays
1) ${array_name[index]} - accessing single element
2) ${array_name[@]} - access all the elements of array
${array_name[*]} - access all the elements of array
3) ${array_name[@]:start_index} - access all the elements of array starts from given index.
4) ${array_name[@]:start_index:No_of_elements} - access given number of elements from given start index.
ARRAYS (DEFINE & ACCESS) IN SHELL SCRIPTING || LINUX || UNIX || ARRAY INITIALIZATION AND ACCESSING
An array is a variable containing multiple values. Any variable may be used as an array. There is no maximum limit to the size of an array, nor any requirement that member variables be indexed or assigned contiguously. Arrays are zero-based: the first element is indexed with the number 0.
Define Array
1) array_name[index]=val1
array_name[index]=val2
- - - - -
2) array_name=(val1 val2 val3 .........)
3) array_name=([index]=val1 [index]=val2 [index]=val3 . . . . .)
Access Elements of Arrays
1) ${array_name[index]} - accessing single element
2) ${array_name[@]} - access all the elements of array
${array_name[*]} - access all the elements of array
3) ${array_name[@]:start_index} - access all the elements of array starts from given index.
4) ${array_name[@]:start_index:No_of_elements} - access given number of elements from given start index.