colrm command in Linux with examples

colrm command in Linux is used for editing text in source code files, script files or regular text files. This command removes selected columns from a file. A column is defined as a single character in a line.

  • It always starts at index 1 and not 0.
  • If both start and end are specified, then the columns between them, including start and end will be removed.
  • If only one specific column needs to be deleted, then start and end must be the same.
  • colrm can also take input from stdin.

Syntax:

colrm [start] [stop]

Example 1: Here, we take input from stdin. Here the start and end are different. So all the characters between start and end, including start and end will be removed. Same can be used on a file (See example 2)

In the example given below, we take input form stdin. Here the start and end column are same i.e 6. So only the sixth character will be removed.

Example 2: Here, we first make a text file using cat command and then use colrm on the file.



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.