Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

An example of using tee Command in Linux system

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article focuses on "examples of the use of tee commands in the Linux system". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "the use of tee commands in the Linux system examples" it!

Name: tee

Location: / usr/bin/tee

Permissions: all users

Function: two-way redirection, which sends the data stream to both the file and the screen, while the output to the screen is stdout, which allows the next command to continue processing.

Usage: tee [OPTION]. [FILE]...

Options:

-a,-append append to the given FILEs, do not overwrite

Additional

Two-way redirection, after the file last.list is written, it can also be output to the screen.

The code is as follows:

Last | tee last.list

Cwjy1202 pts/0: 0 Sat Jan 10 22:14 still logged in

Reboot system boot 3.2.0-24-generic Sat Jan 10 21:45-23:02 (01:16)

Cwjy1202 pts/0: 0.0 Sat Jan 10 19:24-down (00:00)

Reboot system boot 3.2.0-24-generic Sat Jan 10 14:17-19:24 (05:07)

Reboot system boot 3.2.0-24-generic Fri Jan 9 20:50-22:50 (01:59)

Cwjy1202 pts/0: 0 Thu Jan 8 22:08-23:16 (01:08)

Reboot system boot 3.2.0-24-generic Thu Jan 8 21:45-23:17 (01:31)

Cwjy1202 pts/2: 0 Wed Jan 7 23:22-00:27 (01:05)

Cwjy1202 pts/0: 0 Wed Jan 7 23:04-00:27 (01:23)

Reboot system boot 3.2.0-24-generic Wed Jan 7 23:03-00:27 (01:23)

Cwjy1202 pts/2: 0 Tue Jan 6 23:10-23:46 (00:36)

Cwjy1202 pts/0: 0 Tue Jan 6 22:32-23:46 (01:13)

Reboot system boot 3.2.0-24-generic Tue Jan 6 19:32-23:46 (04:13)

Cwjy1202 pts/0: 0 Tue Jan 6 00:24-00:46 (00:21)

Reboot system boot 3.2.0-24-generic Mon Jan 5 20:59-00:46 (03:47)

Cwjy1202 pts/0: 0 Sat Jan 3 20:33-00:39 (04:06)

Cwjy1202 pts/0: 0 Sat Jan 3 19:23-19:24 (00:00)

Reboot system boot 3.2.0-24-generic Sat Jan 3 19:12-00:41 (05:28)

Cwjy1202 pts/2: 0 Sat Jan 3 14:58-17:04 (02:05)

Cwjy1202 pts/1: 0 Sat Jan 3 14:57-17:04 (02:07)

Reboot system boot 3.2.0-24-generic Sat Jan 3 14:54-17:05 (02:10)

Wtmp begins Fri Jan 2 17:17:32 2015

Note: the named tee command does not add the option-a, so the default file will be overwritten.

In the following example, the information of last is written to the file last.list and can also be processed by the sed command

The code is as follows:

$last | tee-a last.list | sed-n '1p'

Cwjy1202 pts/0: 0 Sat Jan 10 22:14 still logged in

At this point, I believe you have a deeper understanding of "the use of tee commands in the Linux system". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report