zoukankan      html  css  js  c++  java
  • 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指令的手册经过过滤,输出到文本文件

    [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                                    //编辑文件内容,没有乱码

    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.

         

  • 相关阅读:
    信息的表示和处理
    Linux基础与Linux下C语言编程基础
    Linux基础入门
    第4次实验
    第三次实验
    第二次实验
    java第一次实验
    数据库提示日志文件不可用
    SQL Server 2012 列存储索引分析(翻译)
    修改delphi xe6 FMX Label字体颜色
  • 原文地址:https://www.cnblogs.com/wj78080458/p/10179240.html
Copyright © 2011-2022 走看看