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
Description | Play: A Playground for awk, grep, jq, sed, and yq |
Difficulty Level | Moderate |
Root or Sudo Privileges | No |
OS Compatibility | Ubuntu, Manjaro, Fedora, etc. |
Prerequisites | – |
Internet Required | Yes (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:
3. Move to the cloned directory and install Play with GoLang.
$ cd play/
$ sudo go build -o /usr/local/bin/
Output:
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:
To create a playground for AWK, simply add it as a parameter to the “play
” command.
$ play awk
Output:
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.
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.
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:
Component | Key | Description |
---|---|---|
Any | Ctrl+C | Exit application. |
Any | Ctrl+S | Exit application and print the input expression to stdout. |
Command Options | Tab | Move focus to positional arguments. |
Command Options | Shift+Tab | Move focus to file picker. |
Command Options | Enter | Move focus to output. |
Positional Arguments | Tab | Move focus to file picker. |
Positional Arguments | Shift+Tab | Move focus to command options. |
Positional Arguments | Enter | Move focus to output. |
Positional Arguments | Ctrl+O | Open wide editor. |
Wide Editor | Esc | Close wide editor. |
Wide Editor | Ctrl+O | Close wide editor. |
Wide Editor | Ctrl+Enter | Enter newline. |
Wide Editor | Enter | Move focus to output. |
File picker | Tab | Move focus to command options. |
File picker | Shift+Tab | Move focus to positional arguments options. |
File picker | Ctrl+O | Open selected file/Close selected file. |
Output | Esc | Move 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.