colrm
Remove columns from a file or input
TLDR
Remove first column of stdin
Remove from 3rd column till the end of each line
Remove from the 3rd column till the 5th column of each line
SYNOPSIS
colrm [startcol [endcol]]
PARAMETERS
startcol
Positive integer (1-based) for first column to remove.
endcol
Optional positive integer for last column to remove; defaults to line end.
DESCRIPTION
colrm is a Unix utility that removes designated columns from lines of text read from standard input, outputting the modified lines to standard output. Columns are numbered starting from 1 at the left edge. It accepts one or two positive integer arguments: the starting column number, and optionally the ending column number.
If only startcol is given, it deletes all characters from that column to the end of each line. With both startcol and endcol, it removes characters from startcol through endcol inclusive.
Column positions account for tabs, which are treated as advancing to the next tab stop every 8 columns (equivalent to expanding tabs into spaces). Backspace characters move the position left by 8 columns. This fixed-width assumption suits legacy fixed-format data like old reports or printer output.
colrm excels at position-based trimming, contrasting with delimiter-based tools like cut. It's stdin-only, so process files via pipes: cat data.txt | colrm 20. Useful for anonymizing fixed-position fields or formatting tables.
Expectations include integer-only args (no validation if endcol < startcol; it removes nothing extra). No file arguments or options in standard implementations.
CAVEATS
Stdin-only; pipe files to use.
Fixed 8-column tabstops; no custom width.
Poor multibyte/UTF-8 support (counts bytes).
No error if endcol < startcol (removes startcol to endcol anyway).
Args must be integers; non-numeric input ignored.
TAB EXPANSION
Tabs count as 1-8 spaces to next multiple of 8 column. E.g., tab in column 1 advances to column 9.
EXAMPLES
echo '1234567890' | colrm 5 → '1234'
echo '1234567890' | colrm 4 7 → '123890'
seq 1 3 | colrm 3 → '1
2
3'
HISTORY
Originated in Programmer's Workbench (PWB) Unix 1.0 around 1977; standardized in POSIX.1-2008. Included in BSD (4.3BSD+), Linux via bsdmainutils package.


