Well I don't really understand awk (I only read the first half of "sed and awk") so I might be missing something here but I had to make some changes to get the script to run at all.
For a start with the script as written I got the following error:so I had to go away and read up on arrays and find that the thing to do was to split the list of masks and bits into an actual array.Code:awk: cmd. line:8: print "\t" $2 "/" ${bits[$i]}; awk: cmd. line:8: ^ syntax errorOn top of all that you declared the masks and bits lists as bash arrays but since awk is interpreting them as strings you can't just sayCode:{ line=0; split(masks, maskarray); split(bits, bitarray); for (i=0; i<=31; i++ ) { if($3 == maskarray[i]) { break; } } print "\t" $2 "/" bitarray[i]; }Instead you need to sayCode:awk -v masks="$masks" bits="$bits"That's definitely enough awk for one day.Code:awk -v masks="${masks[*]}" -v bits="${bits[*]}"




Reply With Quote
