Awk cheatsheet
From Lolly's Wiki
Functions
Binary to decimal
function b2d(bin){
len=length(bin);
for(i=1;i<=len;i++){
dec+=substr(bin,i,1)*2^(len-i);
}
return dec;
}
function b2d(bin){
len=length(bin);
for(i=1;i<=len;i++){
dec+=substr(bin,i,1)*2^(len-i);
}
return dec;
}