find charecter from its ascii value.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting find charecter from its ascii value.
# 1  
Old 11-20-2007
find charecter from its ascii value.

how could find charecter from its ascii value.
please suggest me any code for that.
thannks in advance.
# 2  
Old 11-20-2007
You can use perl's pack function to do that

$hex_ascii=%20;
print "HEX $hex_ascii\n";
$hex_ascii =~ s/%(..)/pack("c",hex($1))/ge;
print "Alpha $hex_ascii\n";

Code above may not suit exactly what you're looking for, but hopefully points in the right direction Smilie

, Mike
# 3  
Old 11-20-2007
You can convert back and forth in a shell script with printf and od. For example a lower case "a" = octal 141...
Code:
$ printf a | od -An -to1
         141
$ printf "\141 \n"
a
$

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Simple question about charecter count

Hi, I have collection of letters in a column such as: AA5678 AA9873434 .. .. I am trying to find the number of charecters in each. "echo "AA5678"|wc -c 7----------------> why does it give 7 instead of 6? (6 Replies)
Discussion started by: kvosu
6 Replies

2. 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

3. Shell Programming and Scripting

to delete charecter in a line

Hi, Using perl, how can I delete a charecter (specify the position number), in a line which starts with "GETR P" and another line starting with "GET P:=". This needs tro be done for many charecters in a line Thanks Vijayalakshmi (2 Replies)
Discussion started by: abc_81
2 Replies

4. Shell Programming and Scripting

`find`, pulling 1st field from ASCII flat file as search/-name?

Hey Everyone! I have searched around for this on Unix.com and Google, and I'm either not phrasing my search properly or this is not as simple as I thought... I have a script that runs on a nightly basis that pulls one field worth of data from an internal MySQL database and populates to an... (2 Replies)
Discussion started by: Gecko12332
2 Replies

5. 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

6. Shell Programming and Scripting

Delete last charecter of each line.

Hi, I have file which is having the following content. 11082202^M 10951265^M 11482003^M 12820986^M 11309561^M 11092815^M 11103308^M 13024722^M 11343958^M 11280355^M 7516723^M i want to delete the last charecter "^M" from all the line and redirect to other line. Please help... (1 Reply)
Discussion started by: shivanete
1 Replies

7. Shell Programming and Scripting

How to find whether a file is transferred thro bin or ascii mode?

Hi Gurus, I need to find out, if i have transferred a file from ftp thro bin mode or ascii mode. Say if i have a file called "dec.sh"( u shuld normally transfer thro ascii mode). How can i find out that dec.sh is tranferred from ftp server thro ascii mode or bin mode? Any help would be... (9 Replies)
Discussion started by: Ashok_oct22
9 Replies

8. UNIX for Dummies Questions & Answers

charecter or number

Hi Friends, How to check a variable value is either charecter or number? With Regards / Ganapati (1 Reply)
Discussion started by: ganapati
1 Replies

9. Shell Programming and Scripting

Comapring files charecter by charecter using AWK/Shell Script

Hi... I have a requrement to compare two files. for e.g. File 1 2007/08/19 09:48:10 DH-032 $APTA1: Device AATD8029 2007/08/19 09:48:10 DH-045 $APTA1: Device AATD8029 2007/08/19 09:48:10 DH-043 $APTA1: Device AATD8029 File 2 2007-08-19 09:48:10 DH-032... (1 Reply)
Discussion started by: evvander
1 Replies

10. Shell Programming and Scripting

cut First charecter in any string

I wannt to cut first char of any string. str=A2465443 out put will be. str1=A str2=2465443. I tried str2=${?%srt} str1=${str#$str2} it is not working. (6 Replies)
Discussion started by: rinku
6 Replies
Login or Register to Ask a Question