[Shell]给linux命令tee输出文件加个时间

24 篇文章 0 订阅
4 篇文章 0 订阅

android  编译 code 的时候习惯加 tee 命令将屏幕上的输出保存到文件,方便编译出错的时候 debug。多次编译会将之前的同一个文件覆盖掉,可以加 -a 进行追加。这里给出一个解决方法:加个时间尾巴。命令如下:


//ls_20150715_194458.log

ls | tee ls_`date +%Y%m%d_%H%M%S`.log 

// 2>&1 把标准错误也被 tee 读取

//build_20150715_195555.log

time make  -j32 sdk 2>&1 |  tee build_`date +%Y%m%d_%H%M%S`.log




$ man tee

NAME
       tee - read from standard input and write to standard output and files

SYNOPSIS
       tee [OPTION]... [FILE]...

DESCRIPTION
       Copy standard input to each FILE, and also to standard output.

       -a, --append
              append to the given FILEs, do not overwrite

       -i, --ignore-interrupts
              ignore interrupt signals

       --help display this help and exit

       --version
              output version information and exit

       If a FILE is -, copy again to standard output.



  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值