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

  • 相关阅读:
    Asp.Net中virtual、override理解
    SQL 知道字段名 全表搜索此字段属于哪个表
    C#中(int)a和Convert.ToInt32(a)的区别
    sql 查询表共多少列
    理解字节和字符
    C# IIS7.0+ Web.Config 配置Session过期时间
    Java版的扫雷游戏源码
    Activiti6.0教程 28张表解析 (三)
    Activiti6.0教程 Service用途剖析 (二)
    Activiti6.0教程 Eclipse安装Activiti Diagram插件(一)
  • 原文地址:https://www.cnblogs.com/embedded-linux/p/6227899.html
Copyright © 2011-2022 走看看