translated

This commit is contained in:
geekpi 2019-12-04 08:57:59 +08:00
parent 3967079ccd
commit 6769a45af6
2 changed files with 121 additions and 132 deletions

View File

@ -1,132 +0,0 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Using multitail on Linux)
[#]: via: (https://www.networkworld.com/article/3445228/using-multitail-on-linux.html)
[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/)
Using multitail on Linux
======
[Glen Bowman][1] [(CC BY-SA 2.0)][2]
The **multitail** command can be very helpful whenever you want to watch activity on a number of files at the same time  especially log files. It works like a multi-windowed **tail -f** command. That is, it displays the bottoms of files and new lines as they are being added. While easy to use in general, **multitail** does provide some command-line and interactive options that you should be aware of before you start to use it routinely.
### Basic multitail-ing
The simplest use of **multitail** is to list the names of the files that you wish to watch on the command line. This command splits the screen horizontally (i.e., top and bottom), displaying the bottom of each of the files along with updates.
[[Get regularly scheduled insights by signing up for Network World newsletters.]][3]
```
$ multitail /var/log/syslog /var/log/dmesg
```
The display will be split like this:
[][4]
BrandPost Sponsored by HPE
[Take the Intelligent Route with Consumption-Based Storage][4]
Combine the agility and economics of HPE storage with HPE GreenLake and run your IT department with efficiency.
```
+-----------------------+
| |
| |
+-----------------------|
| |
| |
+-----------------------+
```
The lines displayed from each of the files would be followed by a single line per file that includes the assigned file number (starting with 00), the file name, the file size, and the date and time the most recent content was added. Each of the files will be allotted half the space available regardless of its size or activity. For example:
```
content lines from my1.log
more content
more lines
00] my1.log 59KB - 2019/10/14 12:12:09
content lines from my2.log
more content
more lines
01] my2.log 120KB - 2019/10/14 14:22:29
```
Note that **multitail** will not complain if you ask it to display non-text files or files that you have no permission to view; you just won't see the contents.
You can also use wild cards to specify the files that you want to watch:
```
$ multitail my*.log
```
One thing to keep in mind is that **multitail** is going to split the screen evenly. If you specify too many files, you will see only a few lines from each and you will only see the first seven or so of the requested files if you list too many unless you take extra steps to view the later files (see the scrolling option described below). The exact result depends on the how many lines are available in your terminal window.
Press **q** to quit **multitail** and return to your normal screen view.
### Dividing the screen
**Multitail** will split your terminal window vertically (i.e., left and right) if you prefer. For this, use the **-s** option. If you specify three files, the right side of your screen will be divided horizontally as well. With four, you'll have four equal-sized windows.
```
+-----------+-----------+ +-----------+-----------+ +-----------+-----------+
| | | | | | | | |
| | | | | | | | |
| | | | +-----------+ +-----------+-----------+
| | | | | | | | |
| | | | | | | | |
+-----------+-----------+ +-----------+-----------+ +-----------+-----------+
2 files 3 files 4 files
```
Use **multitail -s 3 file1 file2 file3** if you want to split the screen into three columns.
```
+-------+-------+-------+
| | | |
| | | |
| | | |
| | | |
| | | |
+-------+-------+-------+
3 files with -s 3
```
### Scrolling
You can scroll up and down through displayed files, but you need to press **b** to bring up a selection menu and then use the up and arrow buttons to select the file you wish to scroll through. Then press the **enter** key. You can then scroll through the lines in an enlarged area, again using the up and down arrows. Press **q** when you're done to go back to the normal view.
### Getting Help
Pressing **h** in **multitail** will open a help menu describing some of the basic operations, though the man page provides quite a bit more information and is worth perusing if you want to learn even more about using this tool.
**Multitail** will not likely be installed on your system by default, but using **apt-get** or **yum** should get you to an easy install. The tool provides a lot of functionality, but with its character-based display, window borders will just be strings of **q**'s and **x**'s. It's a very handy when you need to keep an eye on file updates.
Join the Network World communities on [Facebook][5] and [LinkedIn][6] to comment on topics that are top of mind.
--------------------------------------------------------------------------------
via: https://www.networkworld.com/article/3445228/using-multitail-on-linux.html
作者:[Sandra Henry-Stocker][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/
[b]: https://github.com/lujun9972
[1]: https://www.flickr.com/photos/glenbowman/7992498919/in/photolist-dbgDtv-gHfRRz-5uRM4v-gHgFnz-6sPqTZ-5uaP7H-USFPqD-pbtRUe-fiKiYn-nmgWL2-pQNepR-q68p8d-dDsUxw-dbgFKG-nmgE6m-DHyqM-nCKA4L-2d7uFqH-Kbqzk-8EwKg-8Vy72g-2X3NSN-78Bv84-buKWXF-aeM4ok-yhweWf-4vwpyX-9hu8nq-9zCoti-v5nzP5-23fL48r-24y6pGS-JhWDof-6zF75k-24y6nHS-9hr19c-Gueh6G-Guei7u-GuegFy-24y6oX5-26qu5iX-wKrnMW-Gueikf-24y6oYh-27y4wwA-x4z19F-x57yP4-24BY6gc-24y6nPo-QGwbkf
[2]: https://creativecommons.org/licenses/by-sa/2.0/legalcode
[3]: https://www.networkworld.com/newsletters/signup.html
[4]: https://www.networkworld.com/article/3440100/take-the-intelligent-route-with-consumption-based-storage.html?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE20773&utm_content=sidebar ( Take the Intelligent Route with Consumption-Based Storage)
[5]: https://www.facebook.com/NetworkWorld/
[6]: https://www.linkedin.com/company/network-world

View File

@ -0,0 +1,121 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Using multitail on Linux)
[#]: via: (https://www.networkworld.com/article/3445228/using-multitail-on-linux.html)
[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/)
在 Linux 上使用 Multitail
======
[Glen Bowman][1] [(CC BY-SA 2.0)][2]
当你想同时查看多个文件(尤其是日志文件)的活动时,**multitail** 命令会非常有用。它的工作方式类似于多窗口形式的 **tail -f** 命令。也就是说,它显示文件底部和添加的新行。虽然通常使用简单,但是 **multitail** 提供了一些命令行和交互式选项,在开始使用它之前,你应该了解它们。
### 基本 multitail 使用
**multitail** 的最简单用法是在命令行中列出你要查看的文件名称。此命令水平分割屏幕(即顶部和底部),并显示每个文件的底部以及更新。
```
$ multitail /var/log/syslog /var/log/dmesg
```
显示内容将像这样拆分:
```
+-----------------------+
| |
| |
+-----------------------|
| |
| |
+-----------------------+
```
每个文件都有一行显示该文件的文件编号(从 00 开始)、文件名、文件大小、最新内容的添加日期和时间。每个文件将被分配一半空间,而不论它的大小和活动情况。比如:
```
content lines from my1.log
more content
more lines
00] my1.log 59KB - 2019/10/14 12:12:09
content lines from my2.log
more content
more lines
01] my2.log 120KB - 2019/10/14 14:22:29
```
请注意,如果你要求 **multitail** 显示非文本文件或者你无权查看的文件,它不会报错。你只是看不到内容。
你还可以使用通配符指定要查看的文件:
```
$ multitail my*.log
```
要记住的一件事是,**multitail** 将平均分割屏幕。如果指定的文件太多,那么除非你采取额外的步骤查看之后的文件(参考下面的滚动选项),否则你将只会看到前面 7 个文件的前面几行。确切的结果取决于终端窗口中有多少行可用。
**q** 退出 **multitail** 并返回到正常的屏幕视图。
### 分割屏幕
如果你愿意,**multitail** 将垂直分割你的终端窗口(即,左和右)。为此,请使用 **-s** 选项。如果指定了三个文件,那么屏幕右侧的窗口将会水平分隔。四个文件的话,你将拥有四个大小相等的窗口。
```
+-----------+-----------+ +-----------+-----------+ +-----------+-----------+
| | | | | | | | |
| | | | | | | | |
| | | | +-----------+ +-----------+-----------+
| | | | | | | | |
| | | | | | | | |
+-----------+-----------+ +-----------+-----------+ +-----------+-----------+
2 个文件 3 个文件 4 个文件
```
如果要将屏幕分为三列,请使用 **multitail -s 3 file1 file2 file3**
```
+-------+-------+-------+
| | | |
| | | |
| | | |
| | | |
| | | |
+-------+-------+-------+
3 个文件带上 -s 3 选项
```
### 滚动
你可以上下滚动文件,但是需要按下 **b** 弹出选择菜单,然后使用向上和向下箭头按钮选择要滚动浏览的文件。然后按下回车键。然后,你可以再次使用向上和向下箭头在放大的区域中滚动浏览各行。完成后按下 **q** 返回正常视图。
### 获得帮助
**multitail** 中按下 **h** 将打开一个帮助菜单,其中描述了一些基本操作,但是手册页提供了更多信息,如果莫想了解更多有关使用此工具的信息,请仔细阅读。
默认情况下,你的系统商不会安装 **multitail**,但是使用 **apt-get****yum** 可以使你轻松安装。该工具提供了许多功能,但是通过基于字符的显示,窗口边框将只是 **q****x** 的字符串。 当你需要关注文件更新时,它非常方便。
加入 [Facebook][5] 和 [LinkedIn][6] 上的 Network World 社区,评论热门主题。
--------------------------------------------------------------------------------
via: https://www.networkworld.com/article/3445228/using-multitail-on-linux.html
作者:[Sandra Henry-Stocker][a]
选题:[lujun9972][b]
译者:[geekpi](https://github.com/geekpi)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/
[b]: https://github.com/lujun9972
[1]: https://www.flickr.com/photos/glenbowman/7992498919/in/photolist-dbgDtv-gHfRRz-5uRM4v-gHgFnz-6sPqTZ-5uaP7H-USFPqD-pbtRUe-fiKiYn-nmgWL2-pQNepR-q68p8d-dDsUxw-dbgFKG-nmgE6m-DHyqM-nCKA4L-2d7uFqH-Kbqzk-8EwKg-8Vy72g-2X3NSN-78Bv84-buKWXF-aeM4ok-yhweWf-4vwpyX-9hu8nq-9zCoti-v5nzP5-23fL48r-24y6pGS-JhWDof-6zF75k-24y6nHS-9hr19c-Gueh6G-Guei7u-GuegFy-24y6oX5-26qu5iX-wKrnMW-Gueikf-24y6oYh-27y4wwA-x4z19F-x57yP4-24BY6gc-24y6nPo-QGwbkf
[2]: https://creativecommons.org/licenses/by-sa/2.0/legalcode
[5]: https://www.facebook.com/NetworkWorld/
[6]: https://www.linkedin.com/company/network-world