Re: Which command can transfer a character to hex?

From: Renison, Rick (rick.renison@EDS.COM)
Date: Wed Jul 02 2003 - 13:56:58 EDT


withour perl, I tried
echo '~'|od -An -txC -N1 |head -1
and got back 07e, which is correct.

Zai jian.

> -----Original Message-----
> From: Bill Thompson [mailto:bill.thompson@GOODYEAR.COM]
> Sent: July 1, 2003 7:11 AM
> To: aix-l@Princeton.EDU
> Subject: Re: Which command can transfer a character to hex?
>
>
> Here's one way: perl -e 'printf "%X\n", ord("A");'
>
> This will return the hexadecimal representation of the ASCII
> character "A"
> (41).
>
> If you want to script this (ksh) you could do something like this:
>
> - - - - - snip - - - - -
> #!/bin/sh
>
> export CHAR="B"
>
> HEX=$(perl -e 'printf "%X\n", ord($ENV{CHAR});')
>
> print "$CHAR = $HEX"
> - - - - - snip - - - - -
>
> HTH
>
> Bill Thompson
> Sr UNIX Systems Administrator
> The Goodyear Tire & Rubber Co.
>
> Contains Confidential and/or Proprietary Information
> May Not Be Copied or Disseminated Without Express Consent of
> The Goodyear
> Tire & Rubber Company.
>
> AIX-L Archives: http://marc.theaimsgroup.com/?l=aix-l&r=1&w=2
>
>
> ----- Original Message -----
> From: "augusta Zhou" <meijun_Zhou@SHANGHAIGM.COM>
> Newsgroups: bit.listserv.aix-l
> To: <aix-l@Princeton.EDU>
> Sent: Monday, June 30, 2003 8:56 PM
> Subject: Which command can trasfer a character to hex?
>
> > hi, list
> >
> > I'm search for a command which can transfer a character to
> hex code..
> >
> > Thanks in advance.
> >
> >
> > Best Regards.
> > Zhou Meijun
> >
> > IS Department
> > Shanghai General Motors Co., Ltd.
> >
> > Tel: (021)28902879
> > Fax: (021)50317990
> > E-mail: meijun_zhou@shanghaigm.com
> >
> >
> >
> > ***********************************************************
> > SGM Proprietary
> >
> > The information contained in this electronic communication and its
> attachments (if any) is confidential and subject to legal
> privilege. The
> information is intended only for use of the individuals to whom it is
> addressed. If you are not an intended recipient, or the agent
> or employee
> responsible to deliver it to an intended recipient, you are
> hereby notified
> that any use, dissemination, distribution or copying of this
> communication
> is strictly prohibited. If you have received this electronic
> communication
> in error, please delete it and immediately notify me by
> sending a return
> e-mail to the address in this e-mail. Thank you.
> > ***********************************************************
>



This archive was generated by hypermail 2.1.7 : Wed Apr 09 2008 - 22:16:59 EDT