Wednesday, February 18, 2009

Remove characters using linux colrm command

colrm is a column removal filter.

If only one parameter is specified, the characters of each line will be removed starting from that specified column number.

and if called with two parameters (range of character position to remove) e.g.

$ colrm x y < file.txt

the columns/characters from character position x to character position y will be removed.

Some examples:

# Remove characters from 2nd character position till end
$ echo "abcdefghij" | colrm 2

# Remove characters from 2nd to 5th column position
$ echo "abcdefghij" | colrm 2 5

#The following command deletes the characters in column 4-8 from the file file.txt
$ colrm 4 8 < file.txt

Related post:
- Print or remove first some characters of a string - bash

No comments:

© Jadu Saikia