GoAWK is a command line tool that serves as an alternative to the traditional awk command. Written in the Go programming language, it provides a portable and efficient way to handle text processing tasks like pattern scanning, data extraction, and report generation. This tutorial shows how to install GoAWK on Ubuntu 24.04.
Install GoAWK
Fetch the latest GoAWK release version tag from GitHub and store the version tag in a variable:
GOAWK_VERSION=$(curl -s "https://api.github.com/repos/benhoyt/goawk/releases/latest" | grep -Po '"tag_name": "v\K[0-9.]+')
Next, download tar.gz
file from releases page:
wget -qO goawk.tar.gz https://github.com/benhoyt/goawk/releases/latest/download/goawk_v${GOAWK_VERSION}_linux_amd64.tar.gz
Extract executable to /usr/local/bin
directory:
sudo tar xf goawk.tar.gz -C /usr/local/bin goawk
We can check GoAWK version as follows:
goawk --version
Remove tar.gz
file:
rm -rf goawk.tar.gz
Testing GoAWK
Here's an example of a simple GoAWK command:
goawk -F: '{print $1}' /etc/passwd
The command prints the first field of each line in the /etc/passwd
file. The -F:
option sets the field delimiter to a colon (:
), and {print $1}
specifies that the first field of each line should be output.
Uninstall GoAWK
If you decided to completely remove GoAWK, just delete the related file:
sudo rm -rf /usr/local/bin/goawk
Leave a Comment
Cancel reply