3

好的,所以我只是想知道是否有一种方法可以在脚本运行时在顶部显示进度条,以告诉用户 x% 的过程已完成。还有一个内置在操作系统中的命令可以让我使用进度条还是我必须在代码中设计它?

4

2 回答 2

1

There is zenity, a GTK application with GUI elements for scripts. It has a progress bar and much more.

The package dialog provides several UI elements for shell scripting. One of them is a gauge, a progress bar. Debian maintains a simplified version of dialog called whiptail.

There is also an X version of dialog: Xdialog, but I have never seen it myself.

于 2012-07-15T21:22:12.163 回答
1

在您的脚本中包含一个百分比跟踪器,但会消耗更多资源......

例如,如果您要复制一堆文件:

` foreach $y (@files) {

$countline++;
$total = 1000;
$lastcount = $currentcount
$currentcount = $countline / $total

if ( $lastcount > $currentcount ) {
    $progress_display == 1
    $currentcount

    if ($progress_display == 1) {
            print ".";
    }

} 打印 "\n"; `

于 2012-07-15T19:16:22.400 回答