STRING-JOIN0(1)
β¨ NAME β¨
string-join0 β join strings with zero bytes π
okay so this is the fish-shell manual page for string-join0, and she is literally the main character of NUL-separated joining. Not me being obsessed with zero bytes, but here we are π«Ά.
πΈ SYNOPSIS πΈ
string join [-q | --quiet] [-n | --no-empty] [--] SEP [STRING ...]
string join0 [-q | --quiet] [-n | --no-empty] [--] [STRING ...]
π DESCRIPTION π
Alright bestie, the vibe check: it joins its STRING arguments into one single string separated by SEP (that's string join) or by the zero byte (NUL) (that's string join0). Exit status is 0 if at least one join was performed, or 1 otherwise. Periodt.
The flags are giving very much:
-n,--no-emptyβ exclude empty strings from consideration. Example:string join -n + a b "" cwould expand toa+b+c, nota+b++c. Slay, no empty-string nonsense π .-q,--quietβ don't print the strings, only set the exit status as described above. It's giving silent but observant π.
β οΈ WARNING: Insert a--before positional arguments to prevent them from being interpreted as flags. Otherwise, any strings starting with-will be treated as flag arguments, meaning they will most likely result in the command failing. This is also true if you specify a variable which expands to such a string instead of a literal string. If you don't need to append flag arguments at the end of the command, just always use--to avoid unwelcome surprises. fr fr, protect your peace π«Ά.
string join0 adds a trailing NUL. This is most useful in conjunction with tools that accept NUL-delimited input, such as sort -z. iconic behavior, honestly π₯.
Because Unix uses NUL as the string terminator, passing the output of string join0 as an argument to a command (via a command substitution <# expand-command-substitution>) won't actually work. fish will pass the correct bytes along, but the command won't be able to tell where the argument ends. This is a limitation of Unix' argument passing. yeah, not me crying over Unix argument passing π.
π¦ EXAMPLES π¦
>_ seq 3 | string join ...
1...2...3
# Give a list of NUL-separated filenames to du (this is a GNU extension)
>_ string join0 file1 file2 file\nwith\nmultiple\nlines | du --files0-from=-
# Just put the strings together without a separator
>_ string join '' a b c
abc
>_ set -l markdown_list '- first' '- second' '- third'
# Strings with leading hyphens (also in variable expansions) are interpreted as flag arguments by default.
>_ string join \n $markdown_list
string join: - first: unknown option
# Use '--' to prevent this.
>_ string join -- \n $markdown_list
- first
- second
- third
π«Ά Copyright π«Ά
fish-shell developers π
xoxo, your fish-shell bestie β version 4.9, dated Sep 08, 2026 πβ¨
π¦ where this page comes from
- arch rolling: fish 4.9.3-1 Β· GPL-2.0-only AND BSD-3-Clause AND ISC AND MIT AND PSF-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms