Merge pull request #2142 from GOLinux/master

[Translated] 20141222 A Great Tool To Show Linux Command Progress Like ETA.md
This commit is contained in:
joeren 2014-12-25 08:39:26 +08:00
commit 7ff13e77dc
2 changed files with 97 additions and 98 deletions

View File

@ -1,98 +0,0 @@
Translating by GOLinux!
A Great Tool To Show Linux Command Progress Like ETA
================================================================================
Coreutils Viewer (**cv**) is a simple program that can be used to show the progress of any of coreutils commands. It uses information from file descriptors to determine the progress of a command for example the cp command. The beauty of **cv** is that it can be used with other linux commands like watch and I/O redirection commands as you shall see. This allows you to use it in a script, or however you like, your imagination will be the limit.
### Installation ###
You can download the source files for cv from its [github repository here][1]. Once you have downloaded the zip file extract it and then change directory to the extracted folder.
The program dependencies is the **ncurses library**. If you have installed ncurses in your Linux box then installation of cv will be a breeze.
Compiling and installation can be done in two easy steps.
$ make
$ sudo make install
### Running cv ###
To run cv, just type it on the command line as other programs. If you did not make install and chose to run it from the current directory run the command as follows:
$ ./cv
Otherwise run the command as follows.
$ cv
If there are no coreutils commands running then the cv program will exit and tell you, no coreutils program is running.
![cv no command](http://blog.linoxide.com/wp-content/uploads/2014/11/cv-no-command.png)
To effectively use the program have one of the coreutils programs running on your system. In this case we shall use the command **cp**.
When copying a large file you can see the progress, shown as a percentage
![cv default](http://blog.linoxide.com/wp-content/uploads/2014/11/cv-default.png)
### Adding Options To cv ###
You can also add several option to the cv command just like other commands. One useful option is having to know the estimated time remaining for a copying operation or a move operation particularly for large files.
Adding the **-w** option will just do exactly that.
$ cv -w
![cv estimated throughput](http://blog.linoxide.com/wp-content/uploads/2014/11/cv-estimated-throughput.png)
Try adding more command options. Adding other options like this:
$ cv -wq
### cv And watch Command ###
watch is a program used to run a program periodically and then show the output. Sometimes you might want to see the commands as they are running without storing the data in a log file. In this case watch comes in handy to use with cv.
$ watch cv -qw
This command will show any running instances of coreutils commands. It will also show the progress and the ETA.
![cv and watch](http://blog.linoxide.com/wp-content/uploads/2014/11/cv-and-watch-e1416519384265.png)
### View Output In A Log File ###
As promised, with cv you can redirect its output to a log file. This is particularly useful when the command runs too fast to see anything meaningful.
To see the progress in a log file you can simply redirect the output as in the command below.
$ cv -w >> log.txt
To see the output of this command open the log file with your favourite text editor or with the cat command as follows:
$ cat log.txt
### Getting Help ###
If you get stuck anywhere you can always refer to the man page or the help option.
To get help use cv command with the **-h** option.
$ cv -h
If you need more detailed information then the man page would be a great place to visit.
$ man cv
However, to get the man page with the above command, ensure that you make install cv.
Yay! Now you have another great tool in your Linux toolbox.
--------------------------------------------------------------------------------
via: http://linoxide.com/linux-command/tool-show-command-progress/
作者:[Allan Mbugua][a]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
[a]:http://linoxide.com/author/allan/
[1]:http://github.com/Xfennec/cv

View File

@ -0,0 +1,97 @@
一个用%显示Linux命令进度预计完成时间的伟大工具
================================================================================
Coreutils Viewer**cv**是一个简单的程序它可以用于显示任何核心组件命令的进度。它使用文件描述信息来确定一个命令的进度比如cp命令。**cv**之美在于它能够和其它Linux命令一起使用比如你所知道的watch以及I/O重定向命令。这样你就可以在脚本中使用或者你能想到的所有方式别让你的想象力束缚住你。
### 安装 ###
你可以从cv的[github仓库那儿][1]下载所需的源文件。把zip文件下载下来后将它解压缩然后进入到解压后的文件夹。
该程序依赖于**ncurses library**。如果你已经在你的Linux系统中安装了ncurses那么cv的安装过程对你而言就是那么得轻松写意。
通过以下两个简单步骤来进行编译和安装吧。
$ make
$ sudo make install
### 运行cv ###
要运行cv只需要想其它程序一样在命令行输入此命令即可。如果你没有执行make install而选择从当前目录中去运行那么你可以运行以下命令
$ ./cv
否则,就运行以下命令吧。
$ cv
如果没有核心组件命令在运行那么cv程序会退出并告诉你No coreutils is running。
![cv no command](http://blog.linoxide.com/wp-content/uploads/2014/11/cv-no-command.png)
要有效使用该程序,请在你系统上运行某个核心组件程序。在本例中,我们将使用**cp**命令。
当拷贝一个打文件时,你就可以看到进度了,以百分比显示。
![cv default](http://blog.linoxide.com/wp-content/uploads/2014/11/cv-default.png)
### 添加选项到cv ###
你也可以添加几个选项到cv命令就像其它命令一样。一个有用的选项是让你了解到拷贝或移动大文件时的预计剩余时间。
添加**-w**选项,它会帮你做以上这些事。
$ cv -w
![cv estimated throughput](http://blog.linoxide.com/wp-content/uploads/2014/11/cv-estimated-throughput.png)
试着添加更多的命令选项吧。像下面这样添加其它选项:
$ cv -wq
### cv和watch命令 ###
watch是一个用于周期性运行程序并显示输出结果的程序。有时候你可能想要看看命令运行期间的状况而不想存储数据到日志文件中。在这种情况下watch就会派上用场了它可以和cv一起使用。
$ watch cv -qw
该命令将会显示所有运行着的核心组件命令的实例。它也会显示进度和预计完成时间。
![cv and watch](http://blog.linoxide.com/wp-content/uploads/2014/11/cv-and-watch-e1416519384265.png)
### 在日志文件中查看输出结果 ###
正如所承诺的那样你可以使用cv来重定向它的输出结果到一个日志文件。这功能在命令运行太快而看不到任何有意义的内容时特别有用。
要在日志文件中查看进度,你仅仅需要重定向输出结果,就像下面这样。
$ cv -w >> log.txt
要查看该命令的输出结果请用你喜爱的文本编辑器打开日志文件也可以用cat命令就像下面这样
$ cat log.txt
### 获得帮助 ###
如果你在任何地方受到阻碍你总是可以通过查阅手册页或使用help选项来获取帮助信息。
要获取帮助信息,可以使用带**-h**选项的cv命令。
$ cv -h
如果需要更多详细信息,那么手册页是个很不错的地方。
$ man cv
但是要获取上述手册页你必须执行make install来安装cv。
现在你的Linux工具箱中又多了个伟大的工具。
--------------------------------------------------------------------------------
via: http://linoxide.com/linux-command/tool-show-command-progress/
作者:[Allan Mbugua][a]
译者:[GOLinux](https://github.com/GOLinux)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
[a]:http://linoxide.com/author/allan/
[1]:http://github.com/Xfennec/cv