String concatenation
There is no specific operation to represent string concatenation.Space is a string concatenation operatorthat is used to merge two strings.
In the following example, we create three string variables to perform concatenation at different locations. In the statement, str3
contains the concatenated value of str1
and str2
. Each print
statement performs string concatenation with a static string value and AWK variable:
$ vi string.awk BEGIN { OFS="," str1 = "Good" str2 = "Morning" num1 = "10" str3 = str1 " " str2; print "Concatenated string is : " str3 num1 = num1+1 print "string to number conversion on addition : " num1 } $ awk -f string.awk
The output on execution of the preceding code is as follows :
Concatenated string is : Good Morning string to number conversion on addition : 11
Since string concatenation does not have a special operator, it is essential to ensure that it happens at the right time with the right string by enclosing...