## Concat

### Description

Concatenates a file, or a series of files, to a single file or the console. The destination file will be created if it does not exist, though the the append attribute may be used to alter this behavior.

FileSets and/or FileLists are used to select which files are to be concatenated. There is no singular 'file' attribute to specify a single file to cat -- a fileset or filelist must also be used in these cases.

### Parameters

Attribute | Description | Required
destfile | The destination file for the concatenated stream. If not specified the console will be used instead. | No
append | Specifies whether or not the file specified by 'destfile' should be overwritten. Defaults to "no". | No
encoding | Specifies the encoding for the input files. Please see http://java.sun.com/products/jdk/1.2/docs/guide/internat/encoding.doc.html for a list of possible values. Defaults to the platform's default character encoding. | No

### Parameters specified as nested elements

#### fileset

FileSets are used to select files to be concatenated. Note that the order in which the files selected from a fileset are concatenated is not guaranteed. If this is an issue, use multiple filesets or consider using filelists.

#### filelist

FileLists are used to select files to be concatenated. The file ordering in the files attribute will be the same order in which the files are concatenated.

### Examples

Concatenate a string to a file:

      <concat destfile="README">Hello, World!</concat>

Concatenate a series of files to the console:

      <concat>
        <fileset dir="messages" includes="*important*"/>
      </concat>

Concatenate a single file, appending if the destination file exists:

      <concat destfile="NOTES" append="true">
        <filelist dir="notes" files="note.txt"/>
      </concat>

Concatenate a series of files, overwriting if the destination file exists:

      <concat destfile="${docbook.dir}/all-sections.xml">
        <filelist dir="${docbook.dir}/sections"
             files="introduction.xml,overview.xml"/>
        <fileset dir="${docbook.dir}"
             includes="sections/*.xml"
             excludes="introduction.xml,overview.xml"/>
      </concat>

Copyright © 2002 Apache Software Foundation. All Rights Reserved.