1. 程式人生 > >Linux基礎命令---文字過濾coi

Linux基礎命令---文字過濾coi

col

       過濾掉影響閱讀的控制字元,使用重定向符把說明手冊的內容輸出到文字檔案時,控制字元就成亂碼。col指令可以過濾掉控制字元,使文字可讀。col從標磚輸入讀取內容,輸出到標準輸出。col在讀取字元時跟蹤字符集,並確保字符集在輸出時是正確的。如果輸入試圖備份到最後一條重新整理行,col將顯示一條警告訊息。

       此命令的適用範圍:RedHat、RHEL、Ubuntu、CentOS、SUSE、openSUSE、Fedora。

1、語法

       col [-bfpx]  [-lnum] file

 

2、選項列表

選項

說明

--version

顯示命令版本資訊

--help

顯示幫助文件

-b

過濾所有的控制字元

-f

過濾掉RLF字元,忽略HRLF字元

-p

忽略未知的控制字元

-x

將多個空格用tab代替

-lnum

設定緩衝區大小,預設128行

 

3、例項

       將clear指令的手冊經過過濾,輸出到文字檔案

[[email protected] weijie]# man clear > 3.c                  //將手冊從定向到檔案

[[email protected] weijie]# vim 3.c                            //

編輯檔案,內部有很多亂碼,這些都是控制字元

clear(1)                                                             clear(1)

N^HNA^HAM^HME^HE

       c^Hcl^Hle^Hea^Har^Hr - clear the terminal screen

 

S^HSY^HYN^HNO^HOP^HPS^HSI^HIS^HS

       c^Hcl^Hle^Hea^Har^Hr

 

D^HDE^HES^HSC^HCR^HRI^HIP^HPT^HTI^HIO^HON^HN

       c^Hcl^Hle^Hea^Har^Hr clears your screen if this is possible.  It looks in the environ-

       ment for the terminal type and then in the t^Hte^Her^Hrm^Hmi^Hin^Hnf^Hfo^Ho database to  figure

out how to clear the screen.

 

[[email protected] weijie]# man clear | col -b > 3.c                //將手冊內容過濾之後,定向到檔案

[[email protected] weijie]# vim 3.c                                    //編輯檔案內容,沒有亂碼

clear(1)                                                             clear(1)

NAME

clear - clear the terminal screen

 

SYNOPSIS

clear

 

DESCRIPTION

       clear clears your screen if this is possible.  It looks in the environ-

       ment for the terminal type and then in the terminfo database to  figure

       out how to clear the screen.