Skip to content

Terminator

Terminal window
splitby -t "<VALUE>" [selection...]
splitby --terminator="<VALUE>" [selection...]

The value can be a string or hex bytes like 0x0a.

Replaces the record terminator written after each output record.

  • In per-line mode, the default terminator is \n. Use --terminator to replace it with any string.
  • In zero-terminated mode, the default terminator is \0.
  • In whole-string mode, splitby appends the value once after the output, replacing the default trailing newline.

The terminator is only appended when the original record had one — a final line without a trailing newline stays unterminated.

Use a custom separator between records:

Terminal window
printf "a,b\nc,d\n" | splitby "," --terminator="|" 1
# a|c|

Concatenate all records with no separator:

Terminal window
printf "a,b\nc,d\n" | splitby "," --terminator="" 1
# ac

Use a hex value for a non-printable character:

Terminal window
printf "a,b\nc,d\n" | splitby "," --terminator=0x00 1

Use CRLF line endings:

Terminal window
printf "a,b\nc,d\n" | splitby "," --terminator=0x0d0a 1

Whole-string mode with a custom trailing sequence:

Terminal window
printf "a b c" | splitby -w " " --terminator="!" 1-3
# a b c!
  • An empty terminator (--terminator="") concatenates all records with no separator between them.
  • In per-line and zero-terminated modes, the terminator is only added when the original record had one — a final line without a trailing newline will not get one appended.
  • Multi-byte terminators are supported: 0x0d0a for CRLF, for example.