.\" 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-LENGTH" "1" "Nov 13, 2025" "4.2" "fish-shell" .SH NAME string-length \- print string lengths .SH SYNOPSIS .nf \fBstring\fP \fBlength\fP [\fB\-q\fP | \fB\-\-quiet\fP] [\fB\-V\fP | \fB\-\-visible\fP] [\fISTRING\fP \&...] .fi .sp .SH DESCRIPTION .sp \fBstring length\fP reports the length of each string argument in characters. Exit status: 0 if at least one non\-empty \fISTRING\fP was given, or 1 otherwise. .sp With \fB\-V\fP or \fB\-\-visible\fP, it uses the visible width of the arguments. That means it will discount escape sequences fish knows about, account for $fish_emoji_width and $fish_ambiguous_width. It will also count each line (separated by \fB\en\fP) on its own, and with a carriage return (\fB\er\fP) count only the widest stretch on a line. The intent is to measure the number of columns the \fISTRING\fP would occupy in the current terminal. .SH EXAMPLES .INDENT 0.0 .INDENT 3.5 .sp .EX >_ string length \(aqhello, world\(aq 12 >_ set str foo >_ string length \-q $str; echo $status 0 # Equivalent to test \-n \(dq$str\(dq >_ string length \-\-visible (set_color red)foobar # the set_color is discounted, so this is the width of \(dqfoobar\(dq 6 >_ string length \-\-visible 🐟🐟🐟🐟 # depending on $fish_emoji_width, this is either 4 or 8 # in new terminals it should be 8 >_ string length \-\-visible abcdef\er123 # this displays as \(dq123def\(dq, so the width is 6 6 >_ string length \-\-visible a\enbc # counts \(dqa\(dq and \(dqbc\(dq as separate lines, so it prints width for each 1 2 .EE .UNINDENT .UNINDENT .SH COPYRIGHT fish-shell developers .\" Generated by docutils manpage writer. .