Sitemap
Umair

Umair

Full-stack at the system level, from embedded to backend, with a side of DevOps. Email: connect[@]umairk.foo

Member-only story

The One-Character Bash Command You Should Know

3 min readSep 4, 2026

Here is one of those questions I have seen being asked in interviews because it looks much more complicated than it actually is.

Suppose I show you these two Bash loops:

# First loop
while :
do
done

# Second loop
while true
do
done

Then I ask a simple question:

Why is : used in the first one while true is used in the second?

This is where things usually get entertaining. People start looking for some deep difference in behavior. They draw diagrams, write formulas, invent hypotheses, and sometimes become convinced that the two loops must produce different results because, well, why would anyone write two different commands if they did exactly the same thing? Except they do the same thing…………………………

Press enter or click to view image in full size
Photo by Moise M on Unsplash

: is a Bash Command

The first important detail is that : is not special punctuation in this context.

It is a shell builtin. Run it:

:
echo $?

You get:

0

The colon command does nothing and returns a successful exit status. That makes it useful anywhere Bash expects a command whose success or failure controls what happens next and while needs exactly that.

--

--

Full-stack at the system level, from embedded to backend, with a side of DevOps. Email: connect[@]umairk.foo