.\" 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-SUB" "1" "Nov 13, 2025" "4.2" "fish-shell" .SH NAME string-sub \- extract substrings .SH SYNOPSIS .nf \fBstring\fP \fBsub\fP [(\fB\-s\fP | \fB\-\-start\fP) \fISTART\fP] [(\fB\-e\fP | \fB\-\-end\fP) \fIEND\fP] [(\fB\-l\fP | \fB\-\-length\fP) \fILENGTH\fP] [\fB\-q\fP | \fB\-\-quiet\fP] [\fISTRING\fP \&...] .fi .sp .SH DESCRIPTION .sp \fBstring sub\fP prints a substring of each string argument. The start/end of the substring can be specified with \fB\-s\fP/\fB\-e\fP or \fB\-\-start\fP/\fB\-\-end\fP followed by a 1\-based index value. Positive index values are relative to the start of the string and negative index values are relative to the end of the string. The default start value is 1. The length of the substring can be specified with \fB\-l\fP or \fB\-\-length\fP\&. If the length or end is not specified, the substring continues to the end of each STRING. Exit status: 0 if at least one substring operation was performed, 1 otherwise. \fB\-\-length\fP is mutually exclusive with \fB\-\-end\fP\&. .SH EXAMPLES .INDENT 0.0 .INDENT 3.5 .sp .EX >_ string sub \-\-length 2 abcde ab >_ string sub \-s 2 \-l 2 abcde bc >_ string sub \-\-start=\-2 abcde de >_ string sub \-\-end=3 abcde abc >_ string sub \-e \-1 abcde abcd >_ string sub \-s 2 \-e \-1 abcde bcd >_ string sub \-s \-3 \-e \-2 abcde c .EE .UNINDENT .UNINDENT .SH COPYRIGHT fish-shell developers .\" Generated by docutils manpage writer. .