Linux colrm Command
The Linux colrm command is used to filter out specified columns.
The colrm command reads from the standard input device and outputs to the standard output device. Without any parameters, this command does not filter out any columns.
Syntax
colrm [start column number<end column number>]
Parameter Description:
start column number: Specifies the starting number of the column to be deleted.
end column number: Specifies the ending number of the column to be deleted, which can sometimes be omitted.
Examples
Without any parameters, the command does not delete any columns:
colrm
After pressing Enter, the cursor will blink on the first line, waiting for standard input. At this point, input characters, such as "Hello Linux!", and press Enter. The second line will display the same content as the first line. Press Ctrl+C to exit. The terminal will display the following:
cmd@hdd-desktop:~$ colrm
Hello Linux! # Input "Hello Linux!" string
Hello Linux! # Output the previously input string "Hello Linux!"
To delete all content after the 4th column, use the following command:
colrm 4
Similar to the previous example, the standard input waits for input. After the user inputs the string and presses Enter, the following result will be output:
cmd@hdd-desktop:~$ colrm 4
Hello Linux! # Input "Hello Linux!" string
Hel # Output the string with all content after the 4th column deleted
To delete content from specified columns. For example, to delete content from the 4th to the 6th column, use the following command:
colrm 4 6
The output will be as follows:
cmd@hdd-desktop:~$ colrm 4 6
Hello Linux! # Input "Hello Linux!" string
HelLinux! # Output the string with characters from the 4th to the 6th column deleted