Using an interactive shell (REPL)

Using an interactive shell (REPL)

How to:

In Bash, your terminal is essentially a REPL. You type a command; it reads it, evaluates it, prints the outcome, and loops back awaiting your next command. Here’s an example of using Bash as a REPL:

$ echo "Hello, World!"
Hello, World!
$ x=$((6 * 7))
$ echo $x

Your input follows the $ prompt, with the output printed on the next line. Simple, right?

Deep Dive

Bash, short for Bourne Again SHell, is the default shell on many Unix-based systems. It’s an upgrade to the original Bourne shell, built-in the late 1970s. While Bash is a powerful scripting tool, its interactive mode allows you to execute commands line by line.

When considering alternatives, you have the Python REPL (simply type python in your terminal), Node.js (with node), and IPython, an enhanced interactive Python shell. Every language tends to have its own REPL implementation.

Underneath, REPLs are loops that parse your input (commands or code), run it, and return the result to stdout (your screen), often using the language’s interpreter directly. This immediacy of feedback is excellent for learning and prototyping.

See Also