tee命令重定向,tr命令替换详解

命令tee

  • 命令语法
    teee(选项)(参数)

  • 命令描述
    tee命令有两层含义,一是重定向,二是打印输出到屏幕上。

  • 命令选项
    -a:向文件中重定向时使用追加模式(相当于>>);
    -i:忽略中断(interrupt)信号。

  • 命令示例

[root@localhost ~]# cat student
1 sasd
2 dfds
3 sa
2 sa

[root@localhost ~]# cat a.txt
1 sasd
2 dfds
2 sa
3 sa

[root@localhost ~]# > a.txt                        //表示清空内容的意思

[root@localhost ~]# cat student |tee a.txt    //注意:这里的tee表示重定向,使用tee的时候需要用|
1 sasd
2 dfds
3 sa
2 sa

[root@localhost ~]# cat a.txt
1 sasd
2 dfds
3 sa
2 sa

[root@localhost ~]# cat student |tee -a a.txt     //tee -a 表示追加
1 sasd
2 dfds
3 sa
2 sa

[root@localhost ~]# cat a.txt
1 sasd
2 dfds
3 sa
2 sa
1 sasd
2 dfds
3 sa
2 sa

命令tr

  • 命令语法
    tr(选项)(参数)

  • 命令描述
    用于替换

  • 命令示例

[root@localhost ~]# echo 'student' |tr '[sd]' '[SD]'
StuDent
[root@localhost ~]# echo 'student' |tr 's' 'S'
Student
[root@localhost ~]# echo 'student' |tr '[a-z]' '[A-Z]'
STUDENT
[root@localhost ~]# echo 'student' |tr '[a-z]' '1'
1111111
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值