zoukankan      html  css  js  c++  java
  • Linux进阶命令用法

    1.tr命令 可以对来自标准输入的字符进行替换、压缩和删除。它可以将一组字符变成另一组字符

    选项
    -c或——complerment:取代所有不属于第一字符集的字符;
    -d或——delete:删除所有属于第一字符集的字符;
    -s或--squeeze-repeats:把连续重复的字符以单独一个字符表示;
    -t或--truncate-set1:先删除第一字符集较第二字符集多出的字符。
    将输入字符由大写转换为小写:
    echo "HELLO WORLD" | tr 'A-Z' 'a-z'
    hello world
    

     使用tr删除字符:

    echo "hello 123 world 456" | tr -d '0-9'
    hello  world
    

    字符集补集,从输入文本中将不在补集中的所有字符删除:

    echo aa.,a 1 b#$bb 2 c*/cc 3 ddd 4 | tr -d -c '0-9 
    '
     1  2  3  4
    

     用tr压缩字符,可以压缩输入中重复的字符:

    echo "thissss is      a text linnnnnnne." | tr -s ' sn'
    this is a text line.
    

     删除Windows文件“造成”的'^M'字符:

    cat file | tr -s "
    " "
    " > new_file
    或
    cat file | tr -d "
    " > new_file
    
  • 相关阅读:
    反汇编测试20191325
    20191325mystat
    20191325学习笔记8
    20191325学习笔记7
    2.3.1测试 20191325
    20191214-改进ls
    团队作业4
    20191214-反汇编测试
    stat命令的实现-mysate(必做)
    图片
  • 原文地址:https://www.cnblogs.com/tanxiaojun/p/10631232.html
Copyright © 2011-2022 走看看