Play: TUI Playground for (awk, grep, jq, sed, and yq) in Linux

Linux TLDR
Last Updated:
Reading time: 3 minutes

Play is a simple command-line utility that provides you with a playground to experiment with programs like awk, grep, jq, sed, and yq, particularly beneficial during your early days in Linux.

I’ve tried and tested the mentioned commands for a while, and to be honest, I was quite surprised and also disappointed that I didn’t have this tool back in the day when I began my Linux journey.

However, young Linux newcomers have a good chance to use this tool to easily practice important commands responsible for manipulating text, data, or files based on specific conditions or patterns.

In this article, I’ll explain how to install Play on your Linux system and provide a few usage guides.

Tutorial Details

DescriptionPlay: A Playground for awk, grep, jq, sed, and yq
Difficulty LevelModerate
Root or Sudo PrivilegesNo
OS CompatibilityUbuntu, Manjaro, Fedora, etc.
Prerequisites
Internet RequiredYes (for installation)

How to Install Play on Linux

As of writing, the compiled binary is available for Linux, Windows, and macOS from the release page. However, if you are a Linux user, you can also install it via Go.

1. First, open your terminal and install the necessary packages that are required.

#On Debian and Ubuntu
$ sudo apt install git golang

#On Redhat and Fedora
$ sudo dnf install git golang

#On Arch and Manjaro
$ sudo pacman -S git go

2. Clone the project directory.

$ git clone https://github.com/paololazzari/play

Output:

cloning play project directory

3. Move to the cloned directory and install Play with GoLang.

$ cd play/
$ sudo go build -o /usr/local/bin/

Output:

install Play using golang

Once the installation is complete, restart your terminal session, and then you can access Play via the “play” command.

How to Use Play

The usage of Play is pretty straightforward. All you have to do is issue the “play” command to list all the available commands for playground.

$ play

Output:

play output

To create a playground for AWK, simply add it as a parameter to the “play” command.

$ play awk

Output:

awk playground in Play

Here, the playground is divided into three sections: the top is where you type the AWK command options and positional arguments; the bottom left section belongs to output (displaying all your changes); and the right section belongs to the file explorer, from where you can locate a file.

📝
The file explorer will only show the files and directories residing in the directory where the “play” command was executed.

For demonstration purposes, I’ve opened “/etc/group” file, separated the columns using a colon, and listed only the first column from the file, and this is how it looks.

Play awk with group file

As you can see, it’s so easy to use—all you need to know is the command you’re learning (or playing with) in the playground. Also, one thing I find irritating is that the File Explorer can’t find a file by entering a character; instead, you have to manually go up and down to find your file.

Finally, to quit the playground, you can use the “Ctrl+C” shortcut. For other shortcuts, you can refer to the following table:

ComponentKeyDescription
AnyCtrl+CExit application.
AnyCtrl+SExit application and print the input expression to stdout.
Command OptionsTabMove focus to positional arguments.
Command OptionsShift+TabMove focus to file picker.
Command OptionsEnterMove focus to output.
Positional ArgumentsTabMove focus to file picker.
Positional ArgumentsShift+TabMove focus to command options.
Positional ArgumentsEnterMove focus to output.
Positional ArgumentsCtrl+OOpen wide editor.
Wide EditorEscClose wide editor.
Wide EditorCtrl+OClose wide editor.
Wide EditorCtrl+EnterEnter newline.
Wide EditorEnterMove focus to output.
File pickerTabMove focus to command options.
File pickerShift+TabMove focus to positional arguments options.
File pickerCtrl+OOpen selected file/Close selected file.
OutputEscMove focus to previous component.

That’s it for today’s article; if you have any questions or queries related to the topic, please let me know in the comment section.

Till then, peace!

Join The Conversation

Users are always welcome to leave comments about the articles, whether they are questions, comments, constructive criticism, old information, or notices of typos. Please keep in mind that all comments are moderated according to our comment policy.