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指令的手冊經過過濾,輸出到文本檔案
[root@192 weijie]# man clear > 3.c //将手冊從定向到檔案
[root@192 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.
[root@192 weijie]# man clear | col -b > 3.c //将手冊内容過濾之後,定向到檔案
[root@192 weijie]# vim 3.c //編輯檔案内容,沒有亂碼
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.