shell专题——tee工具

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
发布了127 篇原创文章 · 获赞 68 · 访问量 8万+

猜你喜欢

转载自blog.csdn.net/LiuRenyou/article/details/103696567
tee
今日推荐