Re: base conversion inside awk?!?!?



On 15 Mrz., 10:14, "fazlin" <fazlin...@xxxxxxxxx> wrote:
Hi all,

Is there anyway to do base conversions (eg. decimal to hexa,

Use printf (or sprintf) with format specifier "%x".

binary to decimal etc.) inside awk.

Not that I am aware of any builtin. But you can write your own
function...

awk '{r=0;for(i=1;i<=length;i++){r*=2;r+=(substr($0,i,1)!="0")} print
r}'


Janis


Only way i could do was using system() cmd.

Plz lemme know if u have any inputs

Thanks,
Fazlin


.