concatenation

Last edit

Summary: {{{ awk

Changed:

< {{{

to

> {{{ awk

Changed:

< {{{

to

> {{{ awk

Changed:

< {{{

to

> {{{ awk


The awk programming language does not have an explicit concatenation operator

The awk programming language does not have an explicit concatenation operator. Concatenation of strings in awk is achieved by placing strings next to each other within an [[expression?]]. Note that [[whitspace?]] is allowed between the [[value?]]s:

 BEGIN {
   name = "Bob"
   print "Hello " name
 }

Numeric values will be concatenated as strings

Note that concatenation of [[numeric?]] values will occur if whitespace is used between them:

 # This will output 234
 BEGIN {
   print 2   3  4
 }

Precedence

Note that concatenation has a lower precedence than [[addition?]], so unexpected results may occur, if numeric [[value?]]s are represented this way within an [[expression?]]:

 # This will not produce a result of 358
 BEGIN {
   print 2 3  4  + 1 2 3    # This actually produces 23523
 }