# while Loop

*noun*

say it: **“WYL LOOP”** **/ˈwaɪl ˈlup/**

A loop that keeps repeating its commands for as long as a condition stays true.

## What is a **while loop** in bash?

A **while loop** runs a command and, as long as it works (exit code 0), runs the lines between `do` and `done`, then asks again. With `IFS= read -r line` and `done < file`, it works through a file one whole line at a time.

```bash
while IFS= read -r line; do
  echo "Read: $line"
done < flight-log.txt
```

## In a sentence

- “The **while loop** read the flight log one line at a time.”
- “A **while loop** counted down from 5 while n was greater than 0.”

Level: Journeyman · [More Unix terms at this level](https://www.ask-codey.com/glossary?category=unix&level=3)

Updated: November 10, 2026

## In other subjects

- [while Loop in C#](https://www.ask-codey.com/glossary/while-loop-c-sharp)
- [while Loop in Java](https://www.ask-codey.com/glossary/while-loop-java)
- [while Loop in JavaScript](https://www.ask-codey.com/glossary/while-loop-javascript)
- [while Loop in PowerShell](https://www.ask-codey.com/glossary/while-loop-powershell)
- [while Loop in Python](https://www.ask-codey.com/glossary/while-loop)

Source: https://www.ask-codey.com/glossary/while-loop-unix
