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 "" c would expand to a+b+c, not a+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

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