tee command
tee command tail -f foo.log |grep bar | tee bar.log 命令说明: 双向重定向, 从标准输入读取数据, 输出到屏幕上, 同时保存成文件。 格式: tee [-a] file 参数说明: -a: 以累加的方式, 将数据加入到 file 中。 例如: ls -al /home | tee ~/myfile | more,将ls命令的数据存一份到myfile中,同时屏幕也有输出数据。 我使用过的Linux命令之 tee - 重定向输出到多个文件 本文链接: http://codingstandards.iteye.com/blog/833695 (转载请注明链接) 用途说明 在执行Linux命令时,我们可以把输出重定向到文件中,比如 ls >a.txt,这时我们就不能看到输出了,如果我们既想把输出保存到文件中,又想在屏幕上看到输出内容,就可以使用tee命令了。tee命令读取标准输入,把这些内容同时输出到标准输出和 (多个) 文件中 (read from standard input and write to standard output and files. Copy standard input to each FILE, and also to standard output. If a FILE is -, copy again to standard output.) 。在info tee中说道: tee命令可以重定向标准输出到多个文件 (`tee’: Redirect output to multiple files. The `tee’ command copies standard input to standard output and also to any files given as arguments. This is useful when you want not only to send some data down a pipe, but also to save a copy.) 。要注意的是: 在使用管道线时,前一个命令的标准错误输出不会被tee读取。 ...