WHILE(1)
β¨ WHILE(1) β¨
ok so this is the while page from the fish-shell manual, and bestie, it's about to make loops make sense π
πΈ NAME πΈ
while β do a whole set of commands over and over and over again, like your fave playlist on repeat π
π¦ SYNOPSIS π¦
while CONDITION; COMMANDS; end
π DESCRIPTION π
okay so here's the vibe: while runs CONDITION on loop, and every time that condition's exit status comes back as 0, it goes ahead and runs COMMANDS. no cap, that's the whole thing π₯
The exit status of the while loop is the exit status of the last iteration of the COMMANDS that actually ran β or 0 if none of them ever ran at all. (This matches other shells and is POSIX-compatible, so it's giving very "I've done my homework" energy β¨)
You can use and or or for complex conditions, iykyk. And if you want even more complex control, you can hit it with while true containing a break. main character move, honestly π
The -h or --help option displays help about using this command. v helpful of it π«Ά
π EXAMPLE π
while test -f foo.txt; or test -f bar.txt ; echo file exists; sleep 10; end
# outputs 'file exists' at 10 second intervals,
# as long as the file foo.txt or bar.txt exists.
literally so iconic β it just keeps checking and keeps shouting file exists every 10 seconds as long as that file is around ππ
π Copyright π
fish-shell developers
and that's a wrap, bestie! π this was fish-shell manual page, version 4.9, dated Sep 08, 2026 β go forth and loop responsibly ππ
π¦ 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