print ascii value of A


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting print ascii value of A
# 1  
Old 01-06-2009
print ascii value of A

i want to print ascill value of A and also want to print A by its ascii value
please hel me.
(i know ascii of A=97)
# 2  
Old 01-06-2009
https://www.unix.com/shell-programmin...cii-value.html

See if this post helps you.

- nilesh
# 3  
Old 01-06-2009
Not sure where 97 came from for "A". maybe you mean lower case "a".
See: man ascii .

A = 101 in octal
A = 41 in hexadecimal
A = 65 in decimal

a = 141 in octal
a = 61 in hexadecimal
a = 97 in decimal

If you actually mean lower case a, you can use "bc" to change number bases from decimal to octal then use shell echo to display the character.

#!/bin/ksh
CHAR=97
OCT=`echo "obase=8;ibase=10;${CHAR}"|bc`
echo "\0${OCT}"

a
# 4  
Old 01-06-2009
Hammer & Screwdriver To show the ASCII value of "A"

There are probably simpler ways, but I use that 'od...' command often when trying to diagnose data issues. It helps to find strange characters in text.
The first example is the decimal represenation of "A" and the second is the octal representation.

Code:
> echo "A" | od -An -t dC | awk '{print $1}'
65
> echo "A" | od -An -t oC | awk '{print $1}'
101

# 5  
Old 01-06-2009
See https://www.unix.com/unix-dummies-que...character.html

Code:
printf "%d\n" "'a"

...gives 97
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

2. UNIX for Beginners Questions & Answers

Print byte position of extended ascii character

Hello, I am on AIX. When I encounter extended ascii characters and special characters on a file I need to print.. Byte position, actual character and line number. Is there a simple command that can give me the above result ? Thanks in advance (38 Replies)
Discussion started by: rosebud123
38 Replies

3. Shell Programming and Scripting

Convert Hex to Ascii in a Ascii file

Hi All, I have an ascii file in which few columns are having hex values which i need to convert into ascii. Kindly suggest me what command can be used in unix shell scripting? Thanks in Advance (2 Replies)
Discussion started by: HemaV
2 Replies

4. Shell Programming and Scripting

Print the next ASCII character

Hi, In my file, for few field I have to print the next ASCII character for every character. In the below file, I have to do for the 2,3 and 5th fields. Input File ======== 1|abc|def|5|ghi 2|jkl|mno|6|pqr Expected Ouput file ======= 1|bcd|efg|5|hij 2|klm|nop|6|qrs (2 Replies)
Discussion started by: machomaddy
2 Replies

5. Shell Programming and Scripting

Print on the screen a table in ascii

Hi Is there some kind of generator in the internet which could help me to create a table where i will place some values. Trying to do this with echo cmd, but maybe you will suggest me some generator fo r this. thx. ---------- Post updated at 10:59 AM ---------- Previous update was at... (2 Replies)
Discussion started by: presul
2 Replies

6. Shell Programming and Scripting

convert ascii values into ascii characters

Hi gurus, I have a file in unix with ascii values. I need to convert all the ascii values in the file to ascii characters. File contains nearly 20000 records with ascii values. (10 Replies)
Discussion started by: sandeeppvk
10 Replies

7. UNIX for Dummies Questions & Answers

Ascii or Binary?

Hello all, I am working with ftp servers in unix, and always I have to get and put files but I don't know exactly if I have to get or put them as an ascii or binary. Some files that I use are: .txt, .sav, .fmb, .pct, .sh, .ksh, .dat, .log. Somebody can tell me what is the difference between... (2 Replies)
Discussion started by: Geller
2 Replies

8. UNIX for Dummies Questions & Answers

ascii

a silly question but is there a way to display individual ascii values say if i type 65 it will display the letter instead? thanks fo any help. (3 Replies)
Discussion started by: melkor
3 Replies

9. UNIX for Dummies Questions & Answers

Ascii To Hex

How will I display on screen a UNIX ascii file with its HEX equivalent. I want to check whether 0D 0A is coming at the end of the file which I am generating from UNIX. (1 Reply)
Discussion started by: augustinep
1 Replies

10. UNIX for Dummies Questions & Answers

Ascii Color

first post and i hope this doesnt seem silly. being new to Unix, is there any way i can turn on some ansi coloring (similar to linux)? running SCO openserver unix 5.0+ -jamison- (3 Replies)
Discussion started by: Jamison
3 Replies
Login or Register to Ask a Question