The Linux Newbie Guide  ⇒    Fundamentals     Advanced     Supplement   Command Index   ENG⇒中
All rights reserved, please indicate the source when citing
 

The col (colander) command is used to filter out reverse line feeds (RLF)[Note1] and carriage return (CR)[Note2] characters from a text file. These characters are often used in files that contain data meant to be printed on a physical printer, but they can sometimes cause display issues when viewing the file on a terminal or text editor.

The basic syntax of the col command is as follows:
col [OPTIONS] [FILE] .

Here, [OPTIONS] are optional flags that modify the behavior of the col command, and [FILE] is the name of the text file you want to process. If you don't specify a file, col will read from standard input.

Some common options for the col command include:

Here's an example of how you might use the col command:
col -b -x -p input.txt > output.txt .

In this example, the coll command reads the contents of "input.txt", removes reverse line feeds(RLF) and carriage returns(CR), preserves backspaces at the beginning of lines, converts tabs to spaces, and then writes the processed output to "output.txt".

Keep in mind that the col command is somewhat specialized and may not be commonly used in modern Linux systems. It's often used when dealing with legacy text files that contain printer control characters.

For more examples of using col, refer to the provided link.








Note1: reverse line feeds (RLF), Its ASCII code is 0x8D, which is 141 in decimal notation.


A Carriage Return (CR), Its ASCII code is 0x0D, which is 13 in decimal notation.