Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

geting asci value from character 1

Status
Not open for further replies.

koshu

ISP
Apr 18, 2002
22
0
0
IN
how can write a shell program to get asci value of character preseed on keyboard
 
Itried a simple script utilising awk - but it wouldn't work from alpha to numeric, but did work the other way round :
#!/bin/ksh
echo &quot;enter a letter or a number > 64 and < 128..&quot;
read numb
echo $numb|awk '{ printf(&quot;Alpha answer is %c and numeric is %d\n&quot;,$1,$1)}'

Anyone know why single characters won't decode to their ascii value in printf in awk, whereas numerics will convert ? Dickie Bird (:)-)))
 
[tt]read
echo $REPLY| od -b | read x y z
let ASCII=8#${y}
echo $ASCII
[/tt]
Tested...
[tt]
A
65
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top