while for core

Conditionally run a block in a loop.

Signature

> while (cond) (block)

Parameters

  • cond: condition to check
  • block: block to loop if check succeeds

Notes

This command is a parser keyword. For details, check: https://www.nushell.sh/book/thinking_in_nu.html

Examples

Loop while a condition is true

> mut x = 0; while $x < 10 { $x = $x + 1 }