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 shares the specific code of the vue-...
MySQL previously had a query cache, Query Cache. ...
Preface I believe that everyone has been developi...
1. Write a backup script rem auther:www.yumi-info...
Table of contents Dynamically change themes The f...
1. After entering the container cat /etc/hosts It...
Last year, due to project needs, I wrote a crawle...
1. Preliminary preparation (windows7+mysql-8.0.18...
Preface: The Linux host is relatively easy to han...
This article shares the use of js and jQuery tech...
The effect to be achieved: When the mouse is plac...
1.Jenkins installation steps: https://www.jb51.ne...
Table of contents 1. Customize plan tasks 2. Sync...
The installation of mysql-5.7.17 is introduced be...
This article shares with you how to query the sta...