首页 > 其他 > 详细

tr 命令用法

时间:2018-04-07 21:40:25      阅读:197      评论:0      收藏:0      [点我收藏+]

  tr   

 a. 替换全部字符

  [root@bogon scripts]# tr [a-z] [A-Z]  < /etc/fstab    将读出的结果全部替换成大写字母  (取一行作为展示效果)

  UUID=9B81881D-A104-4EF9-A710-1D249ACAEEA3 /BOOT                   XFS     DEFAULTS        0 0

 b. 删除读出字符匹配范围内的全部字符    tr -d ‘abc‘ < /etc/issue    ||  tr -d ‘a-k‘ < /etc/issue

   [root@bogon scripts]# tr -d ‘Kernel‘ < /etc/issue     效果展示

           \S
          \ o a \m

   原文件看下面

   [root@bogon scripts]# head -3 /etc/issue     与上面进行比对效果

          \S
          Kernel \r on an \m

  c. tr  -d ‘a-z‘ < /path/to/file   用法示意

   [root@bogon scripts]# tr -d ‘a-z‘ < /etc/issue   另一种效果展示

   \S
      K \ \

     D.  insert   tee 命令的用法  # cat /etc/issue | tee /tmp/issue.new | tr ‘a-z‘ ‘A-Z‘   把第一个 cat 的结果 tee 命令保存至其它路径  然后把原来的内容传递给 tr 进行处理

   [root@bogon scripts]# cat /etc/issue | tee /tmp/issue.new | tr ‘a-z‘ ‘A-Z‘

          \S
       
  KERNEL \R ON AN \M

 

tr 命令用法

原文:https://www.cnblogs.com/S--S/p/8734580.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!