.\" Man page generated from reStructuredText. . . .nr rst2man-indent-level 0 . .de1 rstReportMargin \\$1 \\n[an-margin] level \\n[rst2man-indent-level] level margin: \\n[rst2man-indent\\n[rst2man-indent-level]] - \\n[rst2man-indent0] \\n[rst2man-indent1] \\n[rst2man-indent2] .. .de1 INDENT .\" .rstReportMargin pre: . RS \\$1 . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin] . nr rst2man-indent-level +1 .\" .rstReportMargin post: .. .de UNINDENT . RE .\" indent \\n[an-margin] .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]] .nr rst2man-indent-level -1 .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. .TH "STRING-COLLECT" "1" "Nov 13, 2025" "4.2" "fish-shell" .SH NAME string-collect \- join strings into one .SH SYNOPSIS .nf \fBstring\fP \fBcollect\fP [\fB\-a\fP | \fB\-\-allow\-empty\fP] [\fB\-N\fP | \fB\-\-no\-trim\-newlines\fP] [\fISTRING\fP \&...] .fi .sp .SH DESCRIPTION .sp \fBstring collect\fP collects its input into a single output argument, without splitting the output when used in a command substitution. This is useful when trying to collect multiline output from another command into a variable. Exit status: 0 if any output argument is non\-empty, or 1 otherwise. .sp A command like \fBecho (cmd | string collect)\fP is mostly equivalent to a quoted command substitution (\fBecho \(dq$(cmd)\(dq\fP). The main difference is that the former evaluates to zero or one elements whereas the quoted command substitution always evaluates to one element due to string interpolation. .sp If invoked with multiple arguments instead of input, \fBstring collect\fP preserves each argument separately, where the number of output arguments is equal to the number of arguments given to \fBstring collect\fP\&. .sp Any trailing newlines on the input are trimmed, just as with \fB\(dq$(cmd)\(dq\fP substitution. Use \fB\-\-no\-trim\-newlines\fP to disable this behavior, which may be useful when running a command such as \fBset contents (cat filename | string collect \-N)\fP\&. .sp With \fB\-\-allow\-empty\fP, \fBstring collect\fP always prints one (empty) argument. This can be used to prevent an argument from disappearing. .SH EXAMPLES .INDENT 0.0 .INDENT 3.5 .sp .EX >_ echo \(dqzero $(echo one\entwo\enthree) four\(dq zero one two three four >_ echo \e\(dq(echo one\entwo\enthree | string collect)\e\(dq \(dqone two three\(dq >_ echo \e\(dq(echo one\entwo\enthree | string collect \-N)\e\(dq \(dqone two three \(dq >_ echo foo(true | string collect \-\-allow\-empty)bar foobar .EE .UNINDENT .UNINDENT .SH COPYRIGHT fish-shell developers .\" Generated by docutils manpage writer. .