The colrm command is a utility in Linux that is used to remove specific columns from a text file. The colrm command reads a text file and removes the specified columns from the file, writing the resulting text to standard output.
To use the colrm command, you will need to specify the starting column number and the number of columns to remove.
To remove the first 3 columns from a text file, use the following command:
# colrm 1 3 output_file.txt
This will remove the first 3 columns from the input file and write the resulting text to the output file.
If you encounter the below error while running the command colrm :
colrm : command not found
you may try installing the below package as per your choice of distribution:
Distribution | Command |
---|---|
Debian | apt-get install bsdmainutils |
Ubuntu | apt-get install bsdmainutils |
Alpine | apk add util-linux |
Arch Linux | pacman -S util-linux |
Kali Linux | apt-get install bsdmainutils |
CentOS | yum install util-linux |
Fedora | dnf install util-linux |
OS X | brew install util-linux |
Raspbian | apt-get install bsdmainutils |
colrm Command Examples
1. Remove first column of stdin:
# colrm 1 1
2. Remove from 3rd column till the end of each line:
# colrm 3
3. Remove from the 3rd column till the 5th column of each line:
# colrm 3 5