DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

(gawk) Concatenation

Info Catalog (gawk) Arithmetic Ops (gawk) Expressions (gawk) Assignment Ops
 
 String Concatenation
 ====================
 
      It seemed like a good idea at the time.
      Brian Kernighan
 
 
 
    There is only one string operation: concatenation.  It does not have
 a specific operator to represent it.  Instead, concatenation is
 performed by writing expressions next to one another, with no operator.
 For example:
 
      $ awk '{ print "Field number one: " $1 }' BBS-list
      -| Field number one: aardvark
      -| Field number one: alpo-net
      ...
 
    Without the space in the string constant after the `:', the line
 would run together.  For example:
 
      $ awk '{ print "Field number one:" $1 }' BBS-list
      -| Field number one:aardvark
      -| Field number one:alpo-net
      ...
 
    Since string concatenation does not have an explicit operator, it is
 often necessary to insure that it happens where you want it to by using
 parentheses to enclose the items to be concatenated.  For example, the
 following code fragment does not concatenate `file' and `name' as you
 might expect:
 
      file = "file"
      name = "name"
      print "something meaningful" > file name
 
 It is necessary to use the following:
 
      print "something meaningful" > (file name)
 
    We recommend that you use parentheses around concatenation in all
 but the most common contexts (such as on the right-hand side of `=').
 
Info Catalog (gawk) Arithmetic Ops (gawk) Expressions (gawk) Assignment Ops
automatically generated byinfo2html