The data types in awk do not need to be defined and are adaptive. Sometimes forced conversion is required. You can complete the following operations:
I. convert an awk string to a number
[Chengmo @ centos5 ~] $ Awk 'In in {a = "100"; B = "10test10"; print (a + B + 0 );}'
110
You only need to connect the variable through "+. Automatically convert the string to an integer type. If the number is not 0, the first non-numeric character is found, which is automatically ignored later.
II. convert awk numbers into strings
[Chengmo @ centos5 ~] $ Awk 'In in {a = 100; B = 100; c = (a "" B); print c }'
100100
You only need to connect the variable with the "" symbol to perform the operation.
3. awk string connection
[Chengmo @ centos5 ~] $ Awk 'In in {a = "a"; B = "B"; c = (a "" B); print c }'
AB
[Chengmo @ centos5 ~] $ Awk 'In in {a = "a"; B = "B"; c = (a + B); print c }'
0
String join operations are performed by the "2", "+" operator. The mode forces the value of the left and right sides to be numeric. Then perform the operation.