Thursday 25 April 2019

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.

Colrm Command, LPI Tutorials and Materials, LPI Certifications, Linux Guides

◈ 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)

colrm command, Linux Command, Linux Certifications, LPI Guides

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.

colrm command, Linux Command, Linux Certifications, LPI Guides

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

colrm command, Linux Command, Linux Certifications, LPI Guides

colrm command, Linux Command, Linux Certifications, LPI Guides

Related Posts

0 comments:

Post a Comment