![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| check for a particular character inside a file and substitute with a given character? | karthikprasathk | AIX | 1 | 07-01-2008 04:29 AM |
| read a variable character by character, substitute characters with something else | vipervenom25 | UNIX for Dummies Questions & Answers | 2 | 06-06-2008 04:18 PM |
| Processing extended ascii character file names in UNIX (BASH scipts) | peli | UNIX for Advanced & Expert Users | 9 | 04-06-2008 06:17 PM |
| Non-ascii character detection (perl or grep) | srinivasan_85 | UNIX for Dummies Questions & Answers | 9 | 02-20-2007 08:38 AM |
| ASCII character to accept logon password | gord | UNIX for Dummies Questions & Answers | 8 | 02-02-2006 03:58 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Ascii value of character?
Is there a way to determine the ascii value of a character? For example, let's say a shell variable has the value 'A'. I would like it's ascii value (e.g. 65 in this case). I would like to do this from a script (preferably ksh).
|
|
||||
|
I just stumbled upon the following...
$ printf "%d" "'A" This will give me 65, so likewise I can certainly do this... $ var=A $ printf "%d" "'${var}" What I don't understand is the single quote immediately preceding the character. This is the only way it'll work, but I've never seen that syntax before. I quickly glanced at the man pages for printf and I still don't fully understand this. Can someone please explain? Thank you. |
|
||||
|
This is not a "pair" of single quotes. It's simply a single quote (by itself) preceding the character (i.e. 'A) . That's what I've never seen before. In fact, if you use a pair of single quotes, the conversion to the ascii value does not work.
|
|
||||
|
Quote:
Quote:
Quote:
Quote:
|
|
|||||
|
This is slightly off topic, but may give a clue:
I use a report generation program (CyberQuery). One option is to output the report as an Excel document. Within Excel, if any cell of the document is all digits, but the source field was Aplha format, the data is preceeded by a single quote. On the spreadsheet you see the data, including leading zeros (if any), but you do not see the leading quote. Only when you select one of those cells, and look up to the cell contents field, do you see the single leading quote. Hope that helps, or at least gives you something to research / consider. |
![]() |
| Bookmarks |
| Tags |
| perl, perl shift, shift, shift perl |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|