zoukankan      html  css  js  c++  java
  • tr用法

    参考:

    http://man.linuxde.net/tr

    shell脚本学习指南

    语法

      tr [options] source-char-list replace-char-list

    用途

      转换字符。例如,将大写字符转换成小写。选项可让你指定要删除的字符,以及将一串重复出现的字符浓缩成一个。

      Translate, squeeze, and/or delete characters from standard input, writing to standard output.

    常用选项

      -c或--complement:取代所有不属于第一字符集的字符;use the complement of source-char-list

      -d或--delete:删除所有属于第一字符集的字符;delete characters in source-char-list, do not translate

      -s或--squeeze-repeats:把连续重复的字符以单独一个字符表示;replace each input sequence of a repeated character that is listed in source-char-list with a single occurrence of that character.

      -t或--truncate-set1:先删除第一字符集较第二字符集多出的字符。

    支持的字符集

           [: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

    举例

      将小写字符转换为大写字母

          tr [:lower:] [:upper:]

  • 相关阅读:
    [ACM]线段树
    [ACM]树形结构基础 & 字典树
    [ACM]前缀和 & 差分 & 位运算 & Hash函数
    [ACM] 贪心 & 栈 & 队列 & 优先队列
    [ACM] BFS & 双端BFS & A* & 双边BFS
    [ACM]Two Point & 尺取 & 离散化 & C++STL( struct重写,容器应用 )
    JavaWeb期末
    [数据结构]权值线段树与可持久化线段树(主席树)
    [数字图像处理](六)插值运算
    [数字图像处理](五)AHE
  • 原文地址:https://www.cnblogs.com/embedded-linux/p/6227899.html
Copyright © 2011-2022 走看看