Re: base conversion inside awk?!?!?
- From: "Janis" <janis_papanagnou@xxxxxxxxxxx>
- Date: 15 Mar 2007 03:23:57 -0700
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
.
- Follow-Ups:
- Re: base conversion inside awk?!?!?
- From: Ed Morton
- Re: base conversion inside awk?!?!?
- References:
- base conversion inside awk?!?!?
- From: fazlin
- base conversion inside awk?!?!?
- Prev by Date: Re: how to using getopt in AIX
- Next by Date: Re: Find -newer
- Previous by thread: base conversion inside awk?!?!?
- Next by thread: Re: base conversion inside awk?!?!?
- Index(es):
Relevant Pages
|