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
There are two special values that can be assign...
Shtml and asp are similar. In files named shtml, s...
Preface Not long ago, I saw an interesting proble...
Table of contents 1. Enter a directory and create...
Find the running container id docker ps Find the ...
Table of contents Preface Install vue-i18n Config...
Management of input and output in the system 1. U...
Part 3: ❤Three ways to overlook backend data rece...
For example: Copy code The code is as follows: <...
Mirroring is also one of the core components of D...
<a href="https://www.jb51.net/" titl...
When we design a page, we often need to center th...
Will UPDATE lock? Will the SQL statement be locke...
Table of contents 1. Basic Use 2. Image quantity ...
1. I downloaded QT5.13 version before, but after ...