• tr


    论文遇到了瓶颈,歇一歇,没用awk完成,纯粹是休息下……

    tr [OPTION]    SET1   [SET2]    file

    说明:

         tr -s  SET1 file  :对于给定的文段,将凡在SET1中的出现的连续的字符都压缩成一个字符。

    echo "abaa    ddxx   gg" | tr -s 'a dxg'
    结果:aba dx g

         tr -d SET1 file :对于给定的文段,删除所有在SET1中出现的字符。

         tr -t SET1 SET2 file : 将SET1 截断成SET2长度,然后依SET1和SET2中字符出现的次序依次做替换。

    ls -l *media* | tr -s ' ' | cut -d ' ' -f 9

         tr -c SET1 [SET2] file : 对于给定的文段,对SET1的补集做操作,一般同其它选项结合使用。

        SETs是指定的字符(串),可以转换的字符如下:

    NNN   character with octal value NNN (1 to 3 octal digits)
    \     backslash
    a     audible BEL
         backspace
    f     form feed
    
         new line
    
         return
    	     horizontal tab
    v     vertical tab
    CHAR1-CHAR2
         all characters from CHAR1 to CHAR2 in ascending(升序) order
    
    [CHAR*]
          in SET2, copies of CHAR until length of SET1
    
    [CHAR*REPEAT]
          REPEAT copies of CHAR, REPEAT octal if starting with 0
    
    [:alnum:]
          all letters and digits
    
    [:alpha:]
          all letters
    
    [:blank:]
          all horizontal whitespace
    
    [:cntrl:]
           all control characters
    
    [:digit:]
            all digits
    
    [:graph:]
           all printable characters, not including space
    
    [:lower:]
           all lower case letters
    
    [:print:]
            all printable characters, including space
    
    [:punct:]
            all punctuation characters
    
    [:space:]
           all horizontal or vertical whitespace
    
    [:upper:]
           all upper case letters
    
    [:xdigit:]
          all hexadecimal digits
    
    [=CHAR=]
           all characters which are equivalent to CHAR
    
    

     将多个空格转成一个空格:
    1、用awk:
      awk '{print $2}' file
    2、一定要用cut的话:
      cat file|tr -s ' '|cut -d' ' -f2

  • 相关阅读:
    下一代的前端构建工具:parcel打包react
    vue or react mvvm里的文字上下滚动
    CSS grid layout demo 网格布局实例
    js页面可视区域懒加载
    Vue双向绑定简单实现
    React Router 4.0中文快速入门
    Array.isArray() 和 isObject() 原生js实现
    60分钟课程: 用egg.js实现增删改查,文件上传和restfulApi, webpack react es6 (一)
    mirror.js 整合redux的好工具
    React-redux及异步获取数据20分钟快速入门
  • 原文地址:https://www.cnblogs.com/openix/p/3477347.html
Copyright © 2020-2023  润新知