文章目录
shell专题——tee工具
tee工具从标准输入读取并写入到标准输出和文件中
语法
tee [选项] 文件名
选项
-a:追加 (默认是覆盖)
例子
echo hello world | tee tee.txt 等价于echo hello world >tee.txt
echo hello world | tee -a tee.txt 等价于echo hello world >>tee.txt
假设有一份v.conf文件如下,我要备份一份文件v.conf.bak(不要#注释,不要空行)
v.conf
#注释
#注释
#注释
/etc/sdsdsd
/vi/sdsd
命令如下
grep -v '^#' v.conf | grep -v '^$' | tee v.conf.bak