datamash uses tabs (ascii character 0x09) as default field
delimiters. Use -W to treat one or more consecutive
whitespace characters as field delimiters. Use -t,
--field-separator to set a custom field delimiter.
The following examples illustrate the various options.
By default, fields are deparated by a single tab tab. Multiple tabs
denotes multiple fields (this is consistent with GNU coreutil’s
$ printf '1\t\t2\n' | datamash sum 3 2 $ printf '1\t\t2\n' | cut -f3 2
Using -W, one or more consecutive whitespace characters are treated as a single field delimiter:
$ printf '1 \t 2\n' | datamash -W sum 2 2 $ printf '1 \t 2\n' | datamash -W sum 3 datamash: invalid input: field 3 requested, line 1 has only 2 fields
Using -t, a custom field delimiter character can be specified. Multiple consecutive delimiters are treated as multiple fields:
$ printf '1,10,,100\n' | datamash -t, sum 4 100