.\" 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 "WHILE" "1" "Nov 13, 2025" "4.2" "fish-shell" .SH NAME while \- perform a set of commands multiple times .SH SYNOPSIS .nf \fBwhile\fP \fICONDITION\fP\fB;\fP \fICOMMANDS\fP\fB;\fP \fBend\fP .fi .sp .SH DESCRIPTION .sp \fBwhile\fP repeatedly executes \fBCONDITION\fP, and if the exit status is 0, then executes \fBCOMMANDS\fP\&. .sp The exit status of the \fBwhile\fP loop is the exit status of the last iteration of the \fBCOMMANDS\fP executed, or 0 if none were executed. (This matches other shells and is POSIX\-compatible.) .sp You can use \fI\%and\fP or \fI\%or\fP for complex conditions. Even more complex control can be achieved with \fBwhile true\fP containing a \fI\%break\fP\&. .sp The \fB\-h\fP or \fB\-\-help\fP option displays help about using this command. .SH EXAMPLE .INDENT 0.0 .INDENT 3.5 .sp .EX while test \-f foo.txt; or test \-f bar.txt ; echo file exists; sleep 10; end # outputs \(aqfile exists\(aq at 10 second intervals, # as long as the file foo.txt or bar.txt exists. .EE .UNINDENT .UNINDENT .SH COPYRIGHT fish-shell developers .\" Generated by docutils manpage writer. .