JIYIK CN >

Current Location:Home > Learning > OPERATING SYSTEM >

Linux filter control character command col

Author:JIYIK Last Updated:2025/04/08 Views:

The function of the col command is to filter control characters. It is also a member of the pipeline command family.

In many UNIX description files, there are RLF control characters. When we use the shell special characters ">" and ">>" to output the contents of the description file to a plain text file, the control characters will become garbled characters. The col command can effectively filter out these control characters.

-x converts the tab key into a space key equivalent

-b When there is a backslash (/) in the text, only the character following the backslash is retained

-f filters out RLF characters but allows HRLF characters to be rendered.

-l <buffer columns> The default memory buffer has 128 columns, and you can specify the buffer size yourself.

As for the usage examples of this command, I will use two examples provided by Bird Brother to illustrate.

Example 1: Use cat -A to display all special keys, and then use col to convert [tab] to blank.

[root@www ~]# cat -A /etc/man.config <== At this time you will see a lot of ^I symbols, that is tab
[root@www ~]# cat /etc/man.config | col -x | cat -A | more
# Hey! In this way, the [tab] key will be replaced by the space bar, and the output will be much more beautiful!
Example 2: Convert the man page of col to a plain text file in /root/col.man
[root@www ~]# man col > /root/col.man
[root@www ~]# vi /root/col.man

COL(1) BSD General Commands Manual COL(1)

N^HNA^HAM^HME^HE
          c^Hco^Hol^Hl - filter reverse line feeds from input
          S^HSY^HYN^HNO^HOP^HPS^HSI^HIS^HS
          c^Hco^Hol^Hl [-^Hb^Hbf^Hfp^Hpx^Hx] [-^Hl^Hl _^Hn_^Hu_^Hm]

# You read it right! Some special buttons in the man page are used as special keys and color displays,
# so this file will have a bunch of weird characters (with ^) as shown above

[root@www ~]# man col | col -b > /root/col.man

col is often used to save man pages as plain text files for easy reference! For detailed usage of other options, use man col.

For reprinting, please send an email to 1244347461@qq.com for approval. After obtaining the author's consent, kindly include the source as a link.

Article URL:

Related Articles

How to Change the Data Type of a Column in Pandas

Publish Date:2025/04/12 Views:139 Category:Python

We will look at methods for changing the data type of columns in a Pandas Dataframe, as well as options like to_numaric , , as_type and infer_objects . We will also discuss how to to_numaric use downcasting the option in . to_numeric Method

Pandas DataFrame Create New Column Based on Other Columns

Publish Date:2025/04/12 Views:135 Category:Python

DataFrame.apply() This tutorial will show you how we can create new columns in Pandas DataFrame based on the values ​​of other columns in the DataFrame by applying functions to each element of a column or using methods. import pandas as

Groupby Index Column in Pandas

Publish Date:2025/04/13 Views:63 Category:Python

groupby This tutorial shows how to categorize data and apply functions to the categories in Python Pandas . Use groupby() the function to group multiple index columns in Pandas with examples. groupby() Group by index column using function i

How to Extract Month and Year from a Datetime Column in Pandas

Publish Date:2025/04/13 Views:75 Category:Python

We can extract the year and month from a Datetime column using pandas.Series.dt.year() the and methods respectively. If the data is not of type, you need to convert it to first . We can also extract the year and month using the and methods

Dropping Duplicate Columns in Pandas

Publish Date:2025/04/12 Views:177 Category:Python

This tutorial explored the concept of removing duplicate columns from a Pandas DataFrame. Dropping Duplicate Columns in Pandas In this tutorial, let us understand how and why to remove identical or similar columns in a Pandas DataFrame. Mos

Flattening Hierarchical Indexes in Pandas Columns

Publish Date:2025/04/12 Views:183 Category:Python

This article will discuss how to flatten a hierarchical index in a Pandas Dataframe column. Groupby aggregation functions are often used to create hierarchical indexes. The used aggregation function will be visible in the hierarchical index

Adding a Column to a Pandas DataFrame

Publish Date:2025/04/12 Views:159 Category:Python

In this tutorial, you will learn to add specific columns to a Pandas DataFrame. Before we start, let's create a dummy DataFrame to work with. Here, we make two DataFrames, namely dat1 and dat2 , and some entries. import pandas as pd dat1 =

Check if a column exists in Pandas

Publish Date:2025/04/12 Views:58 Category:Python

This tutorial demonstrates methods to check if a column in a Pandas Dataframe exists in Python. We will use the IN and NOT IN operators that can be used to perform this operation in Python. Check if a column exists in Pandas using IN the op

Single query to rename and change column type in PostgreSQL

Publish Date:2025/04/11 Views:166 Category:PostgreSQL

This article describes how to rename a column and change its type in PostgreSQL using only a single query. Renaming and changing column types in MySQL In MySQL , if you want to change the column type and rename it, you can use a simple stat

Scan to Read All Tech Tutorials

Social Media
  • https://www.github.com/onmpw
  • qq:1244347461

Recommended

Tags

Scan the Code
Easier Access Tutorial