The hck is a command line tool for processing text that allows you to extract specific sections of each line of a file. The hck can be used as alternative for cut
Linux command. This tutorial explains how to install hck text processing tool on Ubuntu 24.04.
Install hck
Download hck executable from GitHub releases page to /usr/local/bin
directory:
sudo wget -qO /usr/local/bin/hck https://github.com/sstadick/hck/releases/latest/download/hck-linux-amd64
Set execute permission:
sudo chmod a+x /usr/local/bin/hck
Check the hck version to verify the installation:
hck --version
Testing hck
Create a file with sample data:
printf "John,Doe\nJane,Smith\nSam,Brown" > test.txt
Use hck to extract the first field from the file:
hck -d',' -f1 test.txt
Here, the -d','
option specifies the delimiter (a comma), and the -f1
option specifies that you want to extract the first field from each line. The output will be:
John
Jane
Sam
Uninstall hck
To remove hck, delete its corresponding file:
sudo rm -rf /usr/local/bin/hck
Leave a Comment
Cancel reply