Oh, here's another script for doing this:

#!/bin/sh
ival=`echo "$1" | tr 'a-f' 'A-F'`
bc << EOF
obase=16
$ival
EOF

You can change the 16 to 8 or 2 and obase to ibase for decimal to
hex/hex to decimal...

Karl

On Wed, 2004-08-18 at 12:43, Rosenberg Ben wrote:
> Here's a Unix/Linux shell script
> that works like the Pick XTD verb,
> but that doesn't have a 32 bit limit.
>  
> #!/usr/bin/sh
> echo 16 i $1 p | dc
> 
> Note: Hex digits A B C D E F
> must be entered as UPPER CASE.
> 
> "dc" works with integers of 64 bits.
> 
> Actually, "dc" works with integers
> of thousands of bits, but it gets
> a bit slow if you push the limits.
> 
> # What "dc" does in this script:
> # 16  ... push 16 on the stack
> # i   ... use the top of the stack as the input radix
> # $1  ... push shell command line arg on the stack
> # p   ... pop the stack
> 
> Some folks might think the above 2 line
> script just isn't cryptic enough,
> in which case, you can do it this way:
> #!/usr/bin/sh
> echo 16i$1p|dc
> 
> ***
> 
> 
> The information contained in this e-mail message may be privileged 
> and confidential information and is intended only for the use of 
> the individual and/or entity identified in the alias address of 
> this message.  If the reader of this message is not the intended 
> recipient, or an employee or agent responsible to deliver it to the 
> intended recipient, you are hereby requested not to distribute or 
> copy this communication. If you have received this communication in 
> error, please notify us immediately by telephone or return e-mail and 
> delete the original message from your system.
> -------
> u2-users mailing list
> [EMAIL PROTECTED]
> To unsubscribe please visit http://listserver.u2ug.org/
-- 
Karl L. Pearson
Director of IT,
ATS Industrial Supply
Direct: 801-978-4429
Toll-free: 888-972-3182 x29
Fax: 801-972-3888
http://www.atsindustrial.com
[EMAIL PROTECTED]
-------
u2-users mailing list
[EMAIL PROTECTED]
To unsubscribe please visit http://listserver.u2ug.org/

Reply via email to