From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fa528,605aabdb8f59aaec X-Google-Attributes: gidfa528,public Path: controlnews3.google.com!news1.google.com!news.glorb.com!wn14feed!worldnet.att.net!216.196.106.140!border1.nntp.sjc.giganews.com!border2.nntp.sjc.giganews.com!nntp.giganews.com!news1.optus.net.au!optus!news.optus.net.au!53ab2750!not-for-mail From: "TyBreaker" Newsgroups: comp.unix.tru64 References: <60fdd9c9.0405270723.33f51cc3@posting.google.com> Subject: Re: A little UNIX scripting challenge... MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-NNTP-Posting-Host: bud.sge.net Message-ID: Date: Fri, 28 May 2004 05:22:37 GMT NNTP-Posting-Host: 152.91.10.200 X-Complaints-To: andrew.clark@sge.net X-Trace: news.optus.net.au 1085721757 152.91.10.200 (Fri, 28 May 2004 15:22:37 EST) NNTP-Posting-Date: Fri, 28 May 2004 15:22:37 EST Organization: 90East - reports relating to abuse should be sent to andrew.clark@sge.net Xref: controlnews3.google.com comp.unix.tru64:75 Here's a script that'll do it: #!/bin/sh echo "81 ea 70 90 cd 05 8b 95 40 00" | awk '{ print "obase=2" print "ibase=16" for (i=NF; i > 0; i--) print toupper($i) }' | bc | awk '{ printf "%.8d ", $1 }' Any enhancements will be an exercise for the reader! "nikki_wire" wrote in message news:60fdd9c9.0405270723.33f51cc3@posting.google.com... > Hello! > > I am a UNIX novice but I'd like to write a script to decode some > output - I was wondering if anyone could help me out with it? > > Here's what I'd like to do. > > I have some HEX output. eg. 81 ea 70 90 cd 05 8b 95 40 00 > > I'd like to convert that to strict 8 bit binary with a zero as the > filler for the extra characters but starting from the last 2 digits > and working backwards. > So for the above it would become 00 40 95 8b 05 cd 90 70 ea 81 and > then subsequently 00000000 01000000 10010101 10001011 00000101 > 11001101 10010000 01110000 11101010 10000001 (I think that's right!) > > Does anyone have a way to do this? If so I'd appreciate it! > > Thanks > > Nikki