77. Assigning Array Elements (assignment of array elements)
grammar:
|
|
- Arrayname array of name
- Directory string array subscript
- value the value of
the subscript of the array need not be a sequence, and the like from 0-10, can be a string. It can be equivalent to the dictionary. Andpython
almost78. Referring to Array Elements (reference array elements)
When defining an array, even if there is no value, it can also be called. Because the system is assigned a null value1234567awk 'BEGIN {x=item[105];for (105 in item)print "yes";}'yes
It defined item[105]
, but there is no value, but also the call succeeds
79. Browse the Array using For Loop (cycle through the use of arrays)
grammar
|
|
80. Delete Array Element (delete array elements)
grammar
|
|
Cyclic array may also be used to delete all the elements of
the In GAWK , can be used delete arrayname
to delete all array elements
81. Multi Dimensional Array(多维数组)
|
|
下标使用""
时,里面的都算一个下标
而没有分号,使用逗号,
时,则为多维数组
82. SUBSEP - Subscript Separator(下标分隔符)
下标分隔符默认为#
83. Sort Array Values using asort(使用asort
排序数组的值)
asort
函数是将数组的值进行排序后,将下标用数字1-n表示
|
|
See the above example, the output is not sorted sequentially output, because for (x in item)
the output is unordered, can for (i=1; i<= total; i++)
be ordered output
asort does not modify the original value of the assignment
The following example will not modify the original item
array, and creates a new array itemnew
to sort
|
|
84. Sort Array Indexes using (using asorti asorti
value of ordering indexs)
And asort
usage, in that it is not the same sort of objects
Note that if you use
asorti(array)
, it will replace the value of the original array into a sort of post-indexs. So be careful to use, multi-useasorti(array,arraynew)
Original: Large columns Chapter 12. Awk Associative Arrays (associative array)