mirror of
https://github.com/LCTT/TranslateProject.git
synced 2024-12-26 21:30:55 +08:00
Merge pull request #757 from zpl1025/master
[translated] Linux more Command - Display Long Text File Per page at a T...
This commit is contained in:
commit
ee2cde88e2
@ -1,3 +1,4 @@
|
||||
zpl1025 translating
|
||||
How to Play Blizzard's Hearthstone: Heroes of Warcraft on Linux
|
||||
================================================================================
|
||||
![](http://i1-news.softpedia-static.com/images/news2/How-to-Play-Blizzard-s-Hearthstone-Heroes-of-Warcraft-on-Linux-424410-3.jpg)
|
||||
@ -57,4 +58,4 @@ via: http://news.softpedia.com/news/How-to-Play-Blizzard-s-Hearthstone-Heroes-of
|
||||
|
||||
[1]:https://plus.google.com/u/0/106295000788676760101/posts/aYfwYEoThJw?cfem=1
|
||||
[2]:http://appdb.winehq.org/objectManager.php?bShowAll=true&bIsQueue=false&bIsRejected=false&sClass=version&sTitle=&sReturnTo=&iId=29747
|
||||
[3]:https://twitter.com/thesilviu
|
||||
[3]:https://twitter.com/thesilviu
|
||||
|
@ -1,120 +0,0 @@
|
||||
zpl1025
|
||||
Linux more Command - Display Long Text File Per page at a Time
|
||||
================================================================================
|
||||
If you are used to working with Linux, you will find a lot of file text in Linux world. Configuration files and log files are usually kept in text format. But those file are usually have long content. You can not view them all in one page. So we need to to pagination to those file. And to do that, we can use **more** command.
|
||||
|
||||
### What is more command ###
|
||||
|
||||
More command is a command for displaying a long text file per page at a time. More command is a built-in command in Linux.
|
||||
|
||||
### How to use more ###
|
||||
|
||||
To use more command, we just need to type :
|
||||
|
||||
$ more file_name
|
||||
|
||||
For example we want to see the content of syslog file located in /var/log directory. We can type :
|
||||
|
||||
$ more /var/log/syslog
|
||||
|
||||
![More command](http://linoxide.com/wp-content/uploads/2014/01/more.png)
|
||||
|
||||
We see that **an indicator on the bottom left**. It show us number 0%. It means that the file is long enough, so the first page is 0% of the total page. To scroll down, use space button. Then we see that the indicator number is increased.
|
||||
|
||||
![Scroll page](http://linoxide.com/wp-content/uploads/2014/01/more_2.png)
|
||||
|
||||
### Limit lines per page ###
|
||||
|
||||
When you run more command, it will fill your screen with the content of the file you are seeing using more. You can limit it into some lines for each page. To do this you can use **-num option**.
|
||||
|
||||
For example, you want to **limit the lines only 12 lines** for each page. Then you can type :
|
||||
|
||||
$ more -12 /var/log/syslog
|
||||
|
||||
![Limit 12 lines only](http://linoxide.com/wp-content/uploads/2014/01/more_12.png)
|
||||
|
||||
Now it will limit 12 lines per page. When you press spacebar to scroll down, it will show you more 12 lines.
|
||||
|
||||
### Display user message ###
|
||||
|
||||
As we knew, more will display an indicator at the bottom left to show our position in percentage. For those who run more at the first time, he/she may guess how to scroll the page down. To avoid this, we can use **-d** option that will make more command display a user message like this “[**Press space to continue, ‘q’ to quit.**]” .
|
||||
|
||||
![More with -d option](http://linoxide.com/wp-content/uploads/2014/01/more_d1.png)
|
||||
|
||||
If user press a button other than button **‘space’ and ‘q’** , then more will display a warning message **“[Press ‘h’ for instructions.]”** .
|
||||
|
||||
![More displaying help message](http://linoxide.com/wp-content/uploads/2014/01/more_d2.png)
|
||||
|
||||
If you press h button, it will display a help message :
|
||||
|
||||
![Display help](http://linoxide.com/wp-content/uploads/2014/01/more_dh.png)
|
||||
|
||||
One of the interesting command is the **b** button. **b button allow you** to go back to previous page. In other word, b button allow you **to scroll up**.
|
||||
|
||||
You can know that you are in the previous page from the line **…backup 1** page at the top left area.
|
||||
|
||||
![Scroll up on More](http://linoxide.com/wp-content/uploads/2014/01/more_back.png)
|
||||
|
||||
### Suppress scroll ###
|
||||
|
||||
With **-c** option, more will not scroll the page. It will clear the previous page and put the next page or lines there.
|
||||
|
||||
$ more -10 -c lynis.log
|
||||
|
||||
![Suppress scroll](http://linoxide.com/wp-content/uploads/2014/01/more_c.png)
|
||||
|
||||
If you press space button, the next page or lines is still at the same size.
|
||||
|
||||
![Suppress scroll](http://linoxide.com/wp-content/uploads/2014/01/more_c2.png)
|
||||
|
||||
### Squeeze multiple blank lines ###
|
||||
|
||||
To squeeze it, we can use **-s** option. Here’s a sample :
|
||||
|
||||
![File with blank lines](http://linoxide.com/wp-content/uploads/2014/01/more_s.png)
|
||||
|
||||
When we add **-s** option :
|
||||
|
||||
$ more -s doc_30.txt
|
||||
|
||||
![Squeeze blank lines](http://linoxide.com/wp-content/uploads/2014/01/more_s2.png)
|
||||
|
||||
### Search string ###
|
||||
|
||||
If your log file is long enough, it’s not easy to find a string that you want. Search string can help you. Using **+/string** can search a string for you and put the keyword on the beginning of the line. Let say we want to search “**dhclient**” in **/var/logs/syslog** file. Then the syntax is :
|
||||
|
||||
$ more +/dhclient /var/log/syslog
|
||||
|
||||
![Search string](http://linoxide.com/wp-content/uploads/2014/01/more_string.png)
|
||||
|
||||
Then to continue the search on the next line, you can press **/ button** following by dhclient word.
|
||||
|
||||
### Display content start with specific line ###
|
||||
|
||||
You can also display a content of file start with specific line using **+num** option. For example we have a file with 15 lines inside it.
|
||||
|
||||
![Multiple lines file](http://linoxide.com/wp-content/uploads/2014/01/more_num1.png)
|
||||
|
||||
Then we want to display a file named doc_30.txt starting from the line number 5. The command will be like this :
|
||||
|
||||
$ more +5 doc_30.txt
|
||||
|
||||
![Start with specific lines](http://linoxide.com/wp-content/uploads/2014/01/more_num2.png)
|
||||
|
||||
### Can we use it to display binary file? ###
|
||||
|
||||
**The answer is No**. More will give you a message about this. Here’s a sample.
|
||||
|
||||
![Displaying binary file](http://linoxide.com/wp-content/uploads/2014/01/more_binary.png)
|
||||
|
||||
### Conclusion ###
|
||||
|
||||
More is one of the basic tool to display a content of text file. More can not be used to display binary file. As usual, we can always type **man more** or **more --help** to explore more detail about the usage of more command.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://linoxide.com/linux-command/linux-more-command/
|
||||
|
||||
译者:[译者ID](https://github.com/译者ID) 校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
@ -0,0 +1,120 @@
|
||||
Linux中的more命令-逐页显示长文本文件
|
||||
================================================================================
|
||||
如果你已经习惯了在Linux系统上工作,那你一定会发现在Linux世界中存在着大量的文本文件。配置文件和日志文件通常都采用文本格式。这些文件通常都有很长的内容,不能在一屏内全部显示。所以在处理这种文件时,我们需要分页显示。这时我们可以用上**more**命令。
|
||||
|
||||
### more是干嘛的 ###
|
||||
|
||||
more是一个用来分页显示大文本文件的命令,它默认是内置在各个Linux发行版中的。
|
||||
|
||||
### 怎么用more ###
|
||||
|
||||
使用more命令,只需要键入:
|
||||
|
||||
$ more file_name
|
||||
|
||||
比如,我们想检查/var/log目录下的日志文件syslog,只需要键入:
|
||||
|
||||
$ more /var/log/syslog
|
||||
|
||||
![more命令](http://linoxide.com/wp-content/uploads/2014/01/more.png)
|
||||
|
||||
然后我们可以看到**在屏幕左下角有个提示**,告诉我们当前的显示比例为0%。看上去这个文件相当大,所以第一页是全部页数的0%。使用空格键可以往下翻页,然后就可以看到提示的百分比会增加。
|
||||
|
||||
![Scroll page](http://linoxide.com/wp-content/uploads/2014/01/more_2.png)
|
||||
|
||||
### 限制每页显示的行数 ###
|
||||
|
||||
在执行more命令的时候,它会占用你终端窗口的全部空间用于显示。但是你可以通过参数**-数字**来限制每页显示的行数。
|
||||
|
||||
例如,你希望每页**限制显示12行**,可以通过下面的命令:
|
||||
|
||||
$ more -12 /var/log/syslog
|
||||
|
||||
![限制每页显示12行](http://linoxide.com/wp-content/uploads/2014/01/more_12.png)
|
||||
|
||||
现在,你会看到每页只显示12行,在按下空格键后,就会翻页显示后面的12行。
|
||||
|
||||
### Display user message ###
|
||||
|
||||
我们知道,more命令会在显示区域的左下角提示当前内容所占的百分比。对于第一次使用more命令的人来说,他或她可能会想知道怎么才能往下翻页。为了避免这种情况,我们可以在执行时增加**-d**参数,这样就会额外显示一行用户信息“[**按空格键继续,‘q‘推出.**]”
|
||||
|
||||
![More with -d option](http://linoxide.com/wp-content/uploads/2014/01/more_d1.png)
|
||||
|
||||
如果用户按了**‘空格‘或’q‘**之外的按键,more会显示一行帮助信息**“ [按‘h’键查看提示。]”**
|
||||
|
||||
![More displaying help message](http://linoxide.com/wp-content/uploads/2014/01/more_d2.png)
|
||||
|
||||
如果按下h键,会显示一个帮助信息:
|
||||
|
||||
![Display help](http://linoxide.com/wp-content/uploads/2014/01/more_dh.png)
|
||||
|
||||
一个有意思的指令是**b**按钮,**b按钮允许你**退回到前面的页面。换句话说,b按钮可以允许**向前翻页**。
|
||||
|
||||
你可以通过左上角的**...前1页**信息来确认当前显示的是前面的页面。
|
||||
|
||||
![在more中往前翻页](http://linoxide.com/wp-content/uploads/2014/01/more_back.png)
|
||||
|
||||
### 禁止滚动 ###
|
||||
|
||||
通过参数**-c**,more命令不会滚动页面,而是直接清除之前的内容,替换为下一页的内容。
|
||||
With **-c** option, more will not scroll the page. It will clear the previous page and put the next page or lines there.
|
||||
|
||||
$ more -10 -c lynis.log
|
||||
|
||||
![Suppress scroll](http://linoxide.com/wp-content/uploads/2014/01/more_c.png)
|
||||
|
||||
如果按下空格键,下一页会仍然有相同的大小。
|
||||
|
||||
![Suppress scroll](http://linoxide.com/wp-content/uploads/2014/01/more_c2.png)
|
||||
|
||||
### 忽略多余的空白行 ###
|
||||
|
||||
使用参数**-s**来忽略多余的空白行,下面是个例子:
|
||||
|
||||
![多个空白行的文件](http://linoxide.com/wp-content/uploads/2014/01/more_s.png)
|
||||
|
||||
当我们增加参数**-s**后:
|
||||
|
||||
$ more -s doc_30.txt
|
||||
|
||||
![忽略了多余空白行](http://linoxide.com/wp-content/uploads/2014/01/more_s2.png)
|
||||
|
||||
### 查找字符串 ###
|
||||
|
||||
如果你的日志文件非常大,那么在其中查找你想要的字符串并不是那么容易。more命令的查找功能可以帮你,通过参数**+/string**可以用来搜索字符串,找到的关键字会显示在第一行。比如我们要在**/var/logs/syslog**文件中搜索“**dhclient**”,那more命令的格式:
|
||||
|
||||
$ more +/dhclient /var/log/syslog
|
||||
|
||||
![查找字符串](http://linoxide.com/wp-content/uploads/2014/01/more_string.png)
|
||||
|
||||
然后,如果要在文件中继续搜索下一个,只需要按下**/按钮**,后面跟有关键字dhclient。
|
||||
|
||||
### 从指定行开始显示 ###
|
||||
|
||||
你也可以通过参数**+数字**来指定开始显示的行,例如,我们有一个15行的文件:
|
||||
|
||||
![多行文件](http://linoxide.com/wp-content/uploads/2014/01/more_num1.png)
|
||||
|
||||
然后我们想从第5行开始显示这个文件的内容,命令看起来会是这个样子:
|
||||
|
||||
$ more +5 doc_30.txt
|
||||
|
||||
![从指定行开始显示](http://linoxide.com/wp-content/uploads/2014/01/more_num2.png)
|
||||
|
||||
### 可以显示二进制文件吗? ###
|
||||
|
||||
**答案是不行**. more命令会提示这样的信息,例如:
|
||||
|
||||
![显示二进制文件](http://linoxide.com/wp-content/uploads/2014/01/more_binary.png)
|
||||
|
||||
### 结论 ###
|
||||
|
||||
more是一个用来查看文本文件的基础工具,它不能用来显示二进制文件。通常,我们可以通过命令**man more**或者**more --help**来获取更多关于more怎么使用的信息。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://linoxide.com/linux-command/linux-more-command/
|
||||
|
||||
译者:[zpl1025](https://github.com/zpl1025) 校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
Loading…
Reference in New Issue
Block a user