一维数组的使用极其常用操作:
访问,排序,去重
eg:
awk '
BEGIN{
info="it is a test aha ha ha ha. test over";
lens=split(info,tA," ");#split
print "len of Arr:"
print length(tA),lens;
print asort(tA);#sort ,return len
print "print Arr disorder: "
for(i in tA)#show as dis order
print i,tA[i]
print "print tA in order:"
len = asort(tA,arr)
for(i=1;i<=len;i++)
print i,arr[i]
print "delete a in tA "
for(i in tA){
if ( tA[i] == "a")
delete tA[i]
}
for(i in tA){
print i,tA[i]
}
print "delte duplicate:"
for(i in tA){
if(!a[tA[i]]++)
print i,tA[i]
}
print "print tA in desc order"
for(i in tA)
print i, tA[i] | "sort -r -n -k2"
}'
多维数组的使用:
本质为一维数组,[i,j]形式存储。默认分隔符为\034。