The
Next, we will familiarize ourselves with the Scenario 1: How to use the tee command The tee command format is: tee [OPTION]... [FILE]... From the definition in the man file, we know that tee reads data from the standard input stream, so here we use a simple command to generate an output stream as the input stream of [mysql@localhost ~]$ ping baidu.com PING baidu.com (220.181.57.216) 56(84) bytes of data. 64 bytes from 220.181.57.216 (220.181.57.216): icmp_seq=1 ttl=128 time=30.1 ms 64 bytes from 220.181.57.216 (220.181.57.216): icmp_seq=2 ttl=128 time=33.1 ms 64 bytes from 220.181.57.216 (220.181.57.216): icmp_seq=3 ttl=128 time=31.9 ms 64 bytes from 220.181.57.216 (220.181.57.216): icmp_seq=4 ttl=128 time=30.9 ms ... Now we want to output to the console and save the content output to another file for other purposes. Then [mysql@localhost ~]$ ping baidu.com | tee ping-baidu.log #Save the content to the ping-baidu.log file while outputting to the console. PING baidu.com (220.181.57.216) 56(84) bytes of data. 64 bytes from 220.181.57.216 (220.181.57.216): icmp_seq=1 ttl=128 time=30.6 ms 64 bytes from 220.181.57.216 (220.181.57.216): icmp_seq=2 ttl=128 time=30.5 ms 64 bytes from 220.181.57.216 (220.181.57.216): icmp_seq=3 ttl=128 time=30.2 ms ^C[mysql@localhost ~]$ cat ping-baidu.log #Check if the file content is consistent with the output PING baidu.com (220.181.57.216) 56(84) bytes of data. 64 bytes from 220.181.57.216 (220.181.57.216): icmp_seq=1 ttl=128 time=30.6 ms 64 bytes from 220.181.57.216 (220.181.57.216): icmp_seq=2 ttl=128 time=30.5 ms 64 bytes from 220.181.57.216 (220.181.57.216): icmp_seq=3 ttl=128 time=30.2 ms Scenario 2: How to append content to a file? In the above operation, the output is to ping-baidu.log. If this file exists, first clear all the contents in the file, and then input the content. This method is not suitable for some scenarios. We hope that each output is appended to the file. In this case, we can specify it through the ping baidu.com | tee -a ping-baidu.log Scenario 3: How to output to multiple files at the same time? Simply append the file name to be input after the ping baidu.com | tee ping.log ping-baidu.log Scenario 4: How to redirect the output of tee command as the input stream of another command Simply add Scenario 5: Raising the permission level to write to a file by using the tee command When we are actually operating the liunx server, when we are configuring certain files, after the configuration is completed and when we save them, we find that our current user does not have the file to save the file. At this time, we feel very frustrated. Is there any solution? At this time, the The specific operation is to enter Scenario 6: How to make tee ignore interrupt events The ping baidu.com | tee -i ping.log refer to: https://www.howtoforge.com/linux-tee-command/ The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: A brief discussion on several ways to implement front-end JS sandbox
>>: MySQL 8.0.16 compressed package installation and configuration method graphic tutorial
This article is from Tom Ewer's Managewp blog,...
Many times, after we install a web service applic...
I won't say much nonsense, let's just loo...
This article shares the specific steps of VMware ...
<br />Sometimes you may be asked questions l...
1. Download and decompress 1. Introduction to Zoo...
This article shares the specific code of JS to ac...
Detailed explanation of replace into example in m...
When using MYSQL, triggers are often used, but so...
Considering that many people now use smartphones, ...
By default, the table title is horizontally cente...
What is a mirror? An image can be seen as a file ...
Table of contents Zabbix monitors Nginx Zabbix mo...
Table of contents 1. How to switch 2. Dynamically...
1. To optimize the query, try to avoid full table...