【转载】Save terminal output to a file
To write the output of a command to a file, there are basically 10 commonly used ways.
Overview:
Please note that the
n.e.in the syntax column means "not existing".
There is a way, but it's too complicated to fit into the column. You can find a helpful link in the List section about it.
|| visible in terminal || visible in file || existing
Syntax || StdOut | StdErr || StdOut | StdErr || file
==========++==========+==========++==========+==========++===========
> || no | yes || yes | no || overwrite
>> || no | yes || yes | no || append
|| | || | ||
2> || yes | no || no | yes || overwrite
2>> || yes | no || no | yes || append
|| | || | ||
&> || no | no || yes | yes || overwrite
&>> || no | no || yes | yes || append
|| | || | ||
| tee || yes | yes || yes | no || overwrite
| tee -a || yes | yes || yes | no || append
|| | || | ||
n.e. (*) || yes | yes || no | yes || overwrite
n.e. (*) || yes | yes || no | yes || append
|| | || | ||
|& tee || yes | yes || yes | yes || overwrite
|& tee -a || yes | yes || yes | yes || append
List:
command > output.txtThe standard output stream will be redirected to the file only, it will not be visible in the terminal. If the file already exists, it gets overwritten.
command >> output.txtThe standard output stream will be redirected to the file only, it will not be visible in the terminal. If the file already exists, the new data will get appended to the end of the file.
command 2> output.txtThe standard error stream will be redirected to the file only, it will not be visible in the terminal. If the file already exists, it gets overwritten.
command 2>> output.txtThe standard error stream will be redirected to the file only, it will not be visible in the terminal. If the file already exists, the new data will get appended to the end of the file.
command &> output.txtBoth the standard output and standard error stream will be redirected to the file only, nothing will be visible in the terminal. If the file already exists, it gets overwritten.
command &>> output.txtBoth the standard output and standard error stream will be redirected to the file only, nothing will be visible in the terminal. If the file already exists, the new data will get appended to the end of the file..
command | tee output.txtThe standard output stream will be copied to the file, it will still be visible in the terminal. If the file already exists, it gets overwritten.
command | tee -a output.txtThe standard output stream will be copied to the file, it will still be visible in the terminal. If the file already exists, the new data will get appended to the end of the file.
(*)
Bash has no shorthand syntax that allows piping only StdErr to a second command, which would be needed here in combination with
teeagain to complete the table. If you really need something like that, please look at "How to pipe stderr, and not stdout?" on Stack Overflow for some ways how this can be done e.g. by swapping streams or using process substitution.command |& tee output.txtBoth the standard output and standard error streams will be copied to the file while still being visible in the terminal. If the file already exists, it gets overwritten.
command |& tee -a output.txtBoth the standard output and standard error streams will be copied to the file while still being visible in the terminal. If the file already exists, the new data will get appended to the end of the file.
【转载】Save terminal output to a file的更多相关文章
- How to save console output to a file in Eclipse
https://coderanch.com/t/278299/java/Writing-output-console-file-system File file = new File("te ...
- [解决]--java_out: User.proto: User.proto: Cannot generate Java output because the file 's
在使用 protocol buffer 的时候,用.proto文件生成代码文件时报错 使用命令 protoc.exe --java_out c:\logs\ User.proto User.proto ...
- save tracking results into csv file for oxuva long-term tracking dataset (from txt to csv)
save tracking results into csv file for oxuva long-term tracking dataset (from txt to csv) 2019-10-2 ...
- How can I save HICON to an .ico file
refer:http://stackoverflow.com/questions/2289894/how-can-i-save-hicon-to-an-ico-file answer1: #inclu ...
- ndk-build 修改输出so位置 (change ndk-build output so lib file path )
期望的目录结构: Folder --- | --- build.bat | --- Source | --- All sources codes *.cpp *.h | --- Android --- ...
- Save matrix to a txt file - matlab 在matlab中将矩阵变量保存为txt格式
Source: Baidu Wenku % Original code has been modified dirMain = 'D:\test\'; fid = fopen([dirMain, 't ...
- 【转载 save】vim键位图。
留图,备用,copy from 网络
- ftp 上传文件时报 cant open output connection for file "ftp://129.28.149.240/shop/web/index.html". Reason: "550 Permission denied.".
原因:没有写入权限 修改权限即可 vsftpd.conf vim /etc/vsftpd.conf write_enable=YES #加入这句
- [转]oracle EBS 基础100问
from:http://www.cnblogs.com/xiaoL/p/3593691.html http://f.dataguru.cn/thread-51057-1-1.html 1001 OR ...
随机推荐
- 【Linux 网络编程】端口
(1)众所周知的端口:0~1023,这些端口由IANA分配和控制它们紧密绑定用于一些服务.常用这些端口的通讯 明确表明了某些协议.例如:21端口为ftp服务端口. (2)注册端口:1024~49 ...
- [转帖]SSH命令总结
SSH命令总结 ssh-keygen ssh-copy-id 等命令自己用过 但是知道的不系统 也知道 转发命令 但是也只是知道一点点... ttps://www.cnblogs.com/chenfa ...
- 【6.12校内test】T1单词序列
[问题描述] 给出两个单词(开始单词和结束单词)以及一个词典.找出从开始单词转换到结束单词, 所需要的最短转换序列.转换的规则如下: 1.每次只能改变一个字母 2.转换过程中出现的单词(除开始单词和结 ...
- rebtree学习
http://www.cnblogs.com/skywang12345/p/3245399.html http://www.cnblogs.com/skywang12345/p/3624177.htm ...
- x系统清理/tmp/文件夹的原理
转自:http://www.opsers.org/base/clean-up-on-the-linux-system-tmp-folder-you-may-want-to-know.html§ 我们知 ...
- 非关系型数据库MongoDB初级使用教程
安装:官网 安装难度不大,依序即可 1.新建存储文件 完成后,打开MongoDBx下载路径,新建名为data的文件夹,在此新建名为db的文件夹,db文件夹即用于存储数据 2.配置文件 在b ...
- 在vue中使用async/await遇到的坑
最近无聊在搞一些新的东西,今天就遇到一个async/await的坑: 因为我用的不是vue官方的脚手架,所以遇到这样的问题: await is a reserved word 这样的警告,我猜应该是缺 ...
- tornado源码简单实现
首先基本的同步流程是: class Index(tornado.web.RequestHandle): def get(self): self.write('hellow,word') app = t ...
- OpenCV处理文件、视频和摄像头
图像的本质(图像可以用数组来表示) import numpy as np import cv2 img = np.zeros((3, 3), dtype=np.uint8) print(img, im ...
- KL散度的理解(GAN网络的优化)
原文地址Count Bayesie 这篇文章是博客Count Bayesie上的文章Kullback-Leibler Divergence Explained 的学习笔记,原文对 KL散度 的概念诠释 ...