Having an interactive program that automatically loads questions and checks the solution is wonderful to have while learning a topic. This TUI app has 60+ beginner to intermediate level exercises for Linux CLI text processing tools.

Sample screenshot for CLI exercises


Last month, I started learning a Python TUI framework called Textual. After working on a 4x4 board game, I made an interactive app to help you test your CLI text processing skills with 60+ beginner to intermediate level exercises.

You'll need Python for this (I used 3.8, it should work for more recent versions too). This app is available on PyPI as cliexercises. Example installation instructions are shown below, adjust them based on your preferences and OS.

# virtual environment
$ python3 -m venv textual_apps
$ cd textual_apps
$ source bin/activate
$ pip install cliexercises

# launch the app
$ cliexercises

To run the app without having to enter the virtual environment again, add this alias to .bashrc (or equivalent):

# you'll have to change the path
alias cliexercises='/path/to/textual_apps/bin/cliexercises'

As an alternative to manually managing such virtual environments, you can use https://github.com/pypa/pipx instead:

$ pipx install cliexercises
$ cliexercises

As yet another alternative, you can install textual (see Textual documentation for more details), clone my TUI-apps repository and run the cli_exercises.py file.

Adjust the terminal dimensions for the widgets to appear properly, for example 84x25 (characters x lines).

Video demo🔗

Brief Guide🔗

  • Press Ctrl+p and Ctrl+n to navigate the questions list.
  • Type the command in the box below the question.
  • Press Enter to execute the command.
    • Output would be displayed below the command box.
    • If the output matches the expected results, the command box will turn green and a reference solution will also be shown.
    • Issues due to errors and timeout (about 2 seconds) will be displayed in red.
  • Press Ctrl+s to show the reference solution if you are unable to solve an exercise.
  • Press Ctrl+t to toggle between light and dark themes.
  • Press Ctrl+q to quit the app.
  • Some basic readline-like shortcuts are supported, for example Ctrl+u, Ctrl+k, Ctrl+w, etc

Your progress is automatically saved and restored. Already answered questions will be skipped.

warning There is no safeguard against the command you are executing. They are treated as if you typed them from a shell session.

For more detailed instructions, visit https://github.com/learnbyexample/TUI-apps/tree/main/CLI-Exercises


The exercises in this app have been adapted from my Command Line ebooks.


I'd highly appreciate your feedback. Please file an issue if there are bugs, crashes, etc.

Hope you find this TUI app useful. Happy learning :)