shell命令之tee命令
linux-dash
A beautiful web dashboard for Linux
项目地址:https://gitcode.com/gh_mirrors/li/linux-dash
·
Linux命令之tee命令
tee命令:
在输出信息的同时把信息记录到文件中
例子:
ls | tee ls.txt 将会在终端上显示ls命令的执行结果,并把执行结果输出到ls.txt文件中,将会覆盖原文件的内容,若无ls.txt文件,将会自动创建该文件
ls | tee -a ls.txt 保留ls.txt文件中原来的内容,并把ls命令的执行结果追加到ls.txt文件的最后,不覆盖原来的内容
ls | tee file1.txt file2.txt
将执行结果同时保存到file1和file2中。
tee命令和>重定向很相似,只有一点点区别,>重定向只会将内容重定向到文件,而不会在终端输出,而tee命令会在输出到终端的同时,将内容重定向到文件。
hellohr:~ hellohr$ ls > ~/Desktop/home.txt
hellohr:~ hellohr$ ls | tee ~/Desktop/home1.txt
Applications
Desktop
Documents
Downloads
Library
Mac快捷键.jpg
Movies
Music
Pictures
Public
WebstormProjects
go
hexo
mykoa
privatechain
shell脚本
srcfile.sh
资料
hellohr:~ hellohr$
上面的两条命令生成的文件home.txt和home1.txt内容是完全一样的,但是第一条命令终端上没有任何输出,第二条输出了相应的结果。
A beautiful web dashboard for Linux
最近提交(Master分支:2 个月前 )
186a802e
added ecosystem file for PM2 4 年前
5def40a3
Add host customization support for the NodeJS version 4 年前
更多推荐

所有评论(0)