Sponsored Content
Full Discussion: Ascii value of character?
Top Forums UNIX for Dummies Questions & Answers Ascii value of character? Post 302234572 by Ygor on Wednesday 10th of September 2008 12:54:06 AM
Old 09-10-2008
Interesting. From info printf...
Quote:
* If the leading character of a numeric argument is `"' or `'' then
its value is the numeric value of the immediately following
character. Any remaining characters are silently ignored if the
`POSIXLY_CORRECT' environment variable is set; otherwise, a
warning is printed. For example, `printf "%d" "'a"' outputs `97'
on hosts that use the ASCII character set, since `a' has the
numeric value 97 in ASCII.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

ASCII character to accept logon password

Hey all, Just found your forum...Looks super rich with info! Can't wait to get through it all. I am currently writing a web app in .net that telnets into a unix server (require uid + passwd), runs a command, and returns that output to be displayed on the web page. I have gotten through the... (8 Replies)
Discussion started by: gord
8 Replies

2. UNIX for Dummies Questions & Answers

Non-ascii character detection (perl or grep)

Hi, Can I know how to grep for lines with non-ascii characters in a file? If not grep, at least can we do it with command-line perl or awk? I tried the functionality of perl, but still could not get the result. Any help?? PS: I was sure that someone should have asked this question... (9 Replies)
Discussion started by: srinivasan_85
9 Replies

3. Shell Programming and Scripting

read in a file character by character - replace any unknown ASCII characters with spa

Can someone help me to write a script / command to read in a file, character by character, replace any unknown ASCII characters with space. then write out the file to a new filename/ Thanks! (1 Reply)
Discussion started by: raghav525
1 Replies

4. UNIX for Dummies Questions & Answers

global search and replacement of a non-ascii character

Hi, I need to do a global search and replacement of a non-ascii character. Let me first give the background of my problem. Very frequently, I need to copy set of references from different sources. Typically, a reference would like this: Banumathy et al., 2002 G. Banumathy, V. Singh and U.... (1 Reply)
Discussion started by: effjay
1 Replies

5. UNIX for Advanced & Expert Users

ASCII Character Set

I thought I would point this out. This has a lot of the non printing characters. ASCII Character Set (7 Replies)
Discussion started by: cokedude
7 Replies

6. UNIX for Dummies Questions & Answers

How to grep for a non-standard ASCII character?

A very simple question but I have scoured the web and can't find an answer. How do I search for a character by ASCII code in a regular expression using grep? For example, we use the End of Medium symbol as a delimiter in certain files. (this is ascii 031 in oct, displays as ^Y) I want to grep... (6 Replies)
Discussion started by: DJR
6 Replies

7. Shell Programming and Scripting

FTP Issue with Non ascii character

I have one file .dat file on windows server containg the following text "Bürki" Now When I am using FTP (get) command from UNIX server the text is appering is as "Bürki" I want to preserve the text in the file on UNIX server as it is in source file. Could you please suggest some... (2 Replies)
Discussion started by: Bhushan D
2 Replies

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

9. Shell Programming and Scripting

Remove some special ascii character

Hello I have this special caracter after retreving rows from sql server: "....spasses: • Entrem al valort 6050108002811 • El donem..." I would like a sed command to remove it..or just know it's ascii code in order to replace it into my sql sentence.. Hope some one knows how to do that.... (7 Replies)
Discussion started by: ldiaz2106
7 Replies

10. UNIX for Dummies Questions & Answers

What is ASCII character?

Hi Guru, I have put one post yesterday and get answer. thanks for your help. my question today is: what is ascii character for following non printable characters: ( we need filter these characters out in another process) ^MM-^E^MM-^E. Old post link: ... (5 Replies)
Discussion started by: ken002
5 Replies
printf(1)						      General Commands Manual							 printf(1)

NAME
printf - format and print arguments SYNOPSIS
format [arg ...] DESCRIPTION
writes formatted arguments to the standard output. The arg arguments are formatted under control of the format operand. format is a character string patterned after the formatting conventions of (see printf(3S)), and contains the following types of objects: characters Characters that are not escape sequences or conversion specifications (as described below) are copied to stan- dard output. escape sequences These are interpreted as non-graphic characters: alert backspace form-feed new-line carriage return tab vertical tab single quote character backslash the 8-bit character whose ASCII code is the 1-, 2-, 3-, or 4-digit octal number n, whose first character must be a zero. conversion specification Specifies the output format of each argument (see below). Arguments following format are interpreted as strings if the corresponding format is either or otherwise they are treated as con- stants. Conversion Specifications Each conversion specification is introduced by the percent character After the character, the following can appear in the sequence indi- cated: flags Zero or more flags, in any order, which modify the meaning of the conversion specification. The flag characters and their meanings are: The result of the conversion is left-justified within the field. The result of a signed conversion always begins with a sign, or <space> If the first character of a signed conversion is not a sign, a space character is prefixed to the result. This means that if the space flag and flag both appear, the space flag is ignored. The value is to be converted to an "alternate form". For and conversions, this flag has no effect. For conversion, it increases the precision to force the first digit of the result to be a zero. For or conversion, a non-zero result has or prefixed to it. For and conversions, the result always contains a radix character, even if no digits follow the radix character. For and conversions, trailing zeros are not removed from the result, contrary to usual behavior. field width An optional string of decimal digits to specify a minimum field width. For an output field, if the converted value has fewer bytes than the field width, it is padded on the left (or right, if the left-adjustment flag, has been given) to the field width. precision The precision specifies the minimum number of digits to appear for the or conversions (the field is padded with leading zeros), the number of digits to appear after the radix character for the and conversions, the maximum number of signifi- cant digits for the conversion, or the maximum number of bytes to be printed from a string in s conversion. The preci- sion takes the form of a period followed by a decimal digit string. A null digit string is treated as a zero. conversion characters A conversion character indicates the type of conversion to be applied: The integer argument is printed a signed decimal or unsigned octal unsigned decimal or unsigned hexadecimal notation and The conversion uses the numbers and letters and the conversion uses the numbers and letters The precision component of the argument specifies the minimum number of digits to appear. If the value being converted can be represented in fewer digits than the specified minimum, it is expanded with leading zeroes. The default precision is 1. The result of converting a zero value with a precision of 0 is no characters. The floating-point number argument is printed in decimal notation in the style , where the number of digits after the radix character, is equal to the precision specification. If the precision is omitted from the argument, six digits are out- put; if the precision is explicitly 0, no radix appears. The floating-point-number argument is printed in the style , where there is one digit before the radix character, and the number of digits after it is equal to the precision. When the precision is missing, six digits are produced; if the precision is 0, no radix charac- ter appears. The conversion character produces a number with introducing the exponent instead of The expo- nent always contains at least two digits. However, if the value to be printed requires an exponent greater than two digits, additional exponent digits are printed as necessary. The floating-point-number argument is printed in style or (or int style in the case of a conversion character), with the precision specifying the number of sig- nificant digits. The style used depends on the value converted; style is used only if the exponent result- ing from the conversion is less than or greater than or equal to the precision. Trailing zeros are remove from the result. A radix character appears only if it is followed by a digit. The first byte of the argument is printed. The argument is taken to be a string, and characters from the string are printed until the end of the string or the number of bytes indicated by the precision specification of the argument is reached. If the precision is omitted from the argument, it is interpreted as infinite and all characters up to the end of the string are printed. Print a character; no argument is converted. Similar to the conversion specifier, except that the string can contain backslash-escape sequences which are then con- verted to the characters they represent. will cause to ignore any remaining characters in the string oper- and containing it, any remaining string operands and any additional characters in the format operand. In no case does a nonexistent or insufficient field width cause truncation of a field; if the result of a conversion is wider than the field width, the field is simply expanded to contain the conversion result. EXTERNAL INFLUENCES
Environment Variables determines the interpretation of arg as single and/or multi-byte characters. determines the language in which messages are displayed. If or is not specified in the environment or is set to the empty string, the value of is used as a default for each unspecified or empty variable. If is not specified or is set to the empty string, a default of "C" (see lang(5)) is used instead of If any internationalization variable contains an invalid setting, printf behaves as if all internationalization variables are set to "C". See environ(5). International Code Set Support Single and multi-byte character code sets are supported. RETURN VALUE
exits with one of the following values: Successful completion. Errors occurred; the exit value is increased by one for each error that occurred up to a maximum of 255. DIAGNOSTICS
If an argument cannot be converted into a form suitable for the corresponding conversion specification, or for any other reason cannot be correctly printed, a diagnostic message is printed to standard error, the argument is output as a string form as it was given on the com- mand line, and the exit value is incremented. EXAMPLES
The following command prints the number 123 in octal, hexadecimal and floating point formats in their alternate form printf "%#o, %#x, %#X, %#f, %#g, %#e " 123 123 123 123 123 123 resulting in the following output Print the outputs with their corresponding field widths and precision: printf "%.6d, %10.6d, %.6f, %.6e, %.6s " 123 123 1.23 123.4 MoreThanSix resulting in the following output SEE ALSO
echo(1), printf(3S). STANDARDS CONFORMANCE
printf(1)
All times are GMT -4. The time now is 12:57 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy