Hi, I have recently installed Suse 8 Enterprise Server on a PC and "awk does not seem to work properly. eg awk "BEGIN {print 051;}" outputs 41. Does anyone know why ? Kieran Swanepoel This email and all contents are subject to the following disclaimer: "http://www.didata.com/disclaimer.asp"
On Thu, 19 Jun 2003, sjb wrote:
kieran.swanepoel@za.didata.com wrote:
awk "BEGIN {print 051;}" outputs 41.
Does anyone know why ?
because you're printing an octal value in decimal?
To clarify that 051 in octal = 0x64 + 5x8 + 1 = 0 + 40 + 1 = 41 [showing off little knowledge, that is all that is there to me :-(] -- Rohit ********************************************************* Disclaimer This message (including any attachments) contains confidential information intended for a specific individual and purpose, and is protected by law. If you are not the intended recipient, you should delete this message and are hereby notified that any disclosure, copying, or distribution of this message, or the taking of any action based on it, is strictly prohibited. ********************************************************* Visit us at http://www.mahindrabt.com
Rohit wrote:
awk "BEGIN {print 051;}" outputs 41.
Does anyone know why ?
because you're printing an octal value in decimal?
To clarify that
051 in octal = 0x64 + 5x8 + 1 = 0 + 40 + 1 = 41
Ooh .. that confuses the whole issue because '0x64' is interpreted as the hex value 64 (100 decimal) in Awk ;-) (Sorry, just being pedantic before going to lunch) sjb
kieran.swanepoel@za.didata.com writes:
I have recently installed Suse 8 Enterprise Server on a PC and "awk does not seem to work properly. eg awk "BEGIN {print 051;}" outputs 41.
It's a documented feature of GNU awk: man awk: Octal and Hexadecimal Constants. Starting with version 3.1 of gawk , you may use C-style octal and hexadecimal constants in your AWK program source code. For example, the octal value 011 is equal to decimal 9, ... The traditional and XPG4 awks found e.g. on Solaris output 51. -- Alexandr.Malusek@imv.liu.se
participants (4)
-
Alexandr Malusek
-
kieran.swanepoel@za.didata.com
-
Rohit
-
sjb