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
$ 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.