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 πŸ˜­πŸ’–


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