awk - Unix, Linux Command---reference
When a string must be converted to a number,the conversion is accomplished usingstrtod(3). A number is converted to a string by using the value of?CONVFMT?as a format string for?sprintf(3),with the numeric value of the variable as the argument. However,even though all numbers in?AWK?are floating-point,integral values are?always?converted as integers. Thus,given <table class="src" cellspacing="5" cellpadding="5"> |
Gawk?performs comparisons as follows: If two variables are numeric,they are compared numerically. If one value is numeric and the other has a string value that is a ‘‘numeric string,’’ then comparisons are also done numerically. Otherwise,the numeric value is converted to a string and a string comparison is performed. Two strings are compared,of course,as strings. Note that the POSIX standard applies the concept of ‘‘numeric string’’ everywhere,even to string constants. However,this is clearly incorrect,andgawk?does not do this. (Fortunately,this is fixed in the next version of the standard.)
Note that string constants,such as?"57",are?not?numeric strings,they are string constants. The idea of ‘‘numeric string’’ only applies to fields,?getline?input,?FILENAME,ARGV?elements,?ENVIRON?elements and the elements of an array created by?split()that are numeric strings. The basic idea is that?user input,and only user input,that looks numeric,should be treated that way.
Uninitialized variables have the numeric value 0 and the string value "" (the null,or empty,string).
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 decimal9,and the hexadecimal value?0x11?is equal to decimal 17.
String Constants
String constants in?AWK?are sequences of characters enclosed between double quotes ("). Within strings,certain?escape sequences?are recognized,as in C. These are:
<table class="src" border="1" cellspacing="0" cellpadding="5">
<tr>
<th width="25%">Tag