linux 下的 tee 命令 和 wc 命令

tee: 向standout(标准输出流,通常是命令执行窗口)输出的同时也将内容输出到文件(read from standard input and write to standard output and files).
1 在 Linux 下, 把 可执行文件 run_cmd 执行log 输出到文件 temp.log 的方式有 :
1) run_cmd > temp.log // 执行log 只会在 temp.log 显示, 不在terminal 显示
2) run_cmd | tee temp.log // 执行log 在temp.log 和 terminal 同时显示
2 把run_cmd 执行log,追加到原有的 temp.log 里
run_cmd | tee -a temp.log
3 把run_cmd 执行log,输出到 temp0.log temp.log 里
run_cmd | tee temp0.log temp1.log
4 直接在tee命令后面接| 和下一个命令,就是按照pipeline的方式来弄
run_cmd | tee temp0.log | wc -l // 显示temp.log的行数

5 wc命令主要用来统计文件的行数(包括空行),加上相应的参数后还可以统计字符、字节数等

wc -c filename: 显示一个文件的字节数
wc -m filename: 显示一个文件的字符数
wc -l filename: 显示一个文件的行数 (l: 小写的L)
wc -L filename: 显示一个文件中的最长行的长度
wc -w filename: 显示一个文件的字数

原文地址:https://www.cnblogs.com/yanli0302/p/13745039.html