zoukankan      html  css  js  c++  java
  • tr 命令

    tr命令常用来替换,

    tr命令可以对来自标准输入的字符进行替换、压缩和删除。它可以将一组字符变成另一组字符,经常用来编写优美的单行命令,作用很强大

    -d, –delete  删除指定的字符, 比如  echo "i2i3ii0i3i4i9i" | tr -d [0-9], 删除字符串中所有的数字,最后输出 “iiiiiiii”

    -d

    [root@localhost sh~]# cat test.txt 
    "helo"
    [root@localhost sh]# cat test.txt |tr -d '"'
    helo

    删除a-zA-Z的字符,还有: ,""字符

    tr -d "a-zA-Z,:""
    [root@localhost sh]# cat 4.txt 
    abcdefg
    
    [root@localhost sh]# cat 4.txt |tr [a-z] [A-Z]      
    ABCDEFG
    
    // 把文件小写字母变成大写字母

    root@H5_521_YUNWEI_119.146.201.90 15:52:49~]# cat test.txt "helo"[root@H5_521_YUNWEI_119.146.201.90 15:52:51~]# cat test.txt |tr -d """> ^C[root@H5_521_YUNWEI_119.146.201.90 15:53:01~]# cat test.txt |tr -d '"'helo

  • 相关阅读:
    unix网络编程 初步了解TCP/IP协议
    unix网络编程 常见概念
    linux 环境变量
    linux c编程
    第二周学习笔记
    jmeter第一周学习笔记
    建造者模式
    原型设计模式
    抽象工厂模式
    工厂方法模式
  • 原文地址:https://www.cnblogs.com/mingerlcm/p/7831885.html
Copyright © 2011-2022 走看看