English 中文(简体)
在古姆(最新情况正在不断更新)期间,我如何每两秒回一次?
原标题:How do I echo a period every 2 seconds while yum -y update is running?

我正在撰写一份文字,以做一些客户服务器的违约配置,并几乎达到100%。

我无法列举的是,如何以某种形式操作<条码>yum -y Update/code>,这种编号与“......每两秒钟”对应,同时更新。

这里是帮助解释略微少一点的典型例子。

YUMLOG=/var/log/config.log
while [ yum -y update > $YUMLOG 2>&1 ]
do
    echo "."
    sleep 2
done

显然,这并不奏效,但我不知道在做些什么改动,以便它能够does<>工作。 我在《法典》中有其他部分给我带来这种进展的阻碍作用,但没有任何部分落空。 例如:

if [ $SETXENNET != "y" ]; then
        sleep 1
        cp $TEMPLATEDIR/rc.local.template $TEMPLATEDIR/rc.local.new
        echo "."
        sleep 1
        cp $TEMPLATEDIR/rc.local.new /etc/rc.local
        echo "."
        sleep 1
        chmod a+x /etc/rc.local
        echo "."
        sleep 1
    else
        sleep 1
        cp $TEMPLATEDIR/rc.local.xen.template $TEMPLATEDIR/rc.local.xen.new
        echo "."
        sleep 1
        cp $TEMPLATEDIR/rc.local.xen.new /etc/rc.local
        echo "."
        sleep 1
        chmod a+x /etc/rc.local
        echo "."
        sleep 1
    fi

而且,在我给所有睡觉的人打上轮椅之前,我必须找到办法,显示文稿的进展,因为管理书的人不会知道他们正在做什么(这只是从一份清单中读出的钥匙,并在做些事情时加以检查)。

因此,我需要一种冰、干净、容易的方式,以便(1) 看到用便衣(即做的或ski的)发生,(2) 视文仍在操作,即使没有显示在屏幕上。

Last, I cannot make a global change to the way I am showing progress, there is too much code to have to make changes to everything it does. But, if that is the absolute only answer, I guess that may be what I have to do...some day...

问题回答

How about something like this? The dots are printed in a function that executes in the background. When yum is finished running, you can kill it.

#!/bin/bash

function dots {
   while : ; do
      echo -n ". "
      sleep 2s
   done
}

dots &
pid=$!

# do real work here
sleep 15s

kill -9 $pid
echo "done!"

你可以这样做。 <代码>yum在背景中工作,首先创建临时档案,然后删除。 主要过程是休息室、睡眠和印刷,而档案存在:

(touch tmpfile ; yum ... ; rm tmpfile)&
(while test -e tmpfile ; do echo . ; sleep 2 ; done)




相关问题
Parse players currently in lobby

I m attempting to write a bash script to parse out the following log file and give me a list of CURRENT players in the room (so ignoring players that left, but including players that may have rejoined)...

encoding of file shell script

How can I check the file encoding in a shell script? I need to know if a file is encoded in utf-8 or iso-8859-1. Thanks

Bash usage of vi or emacs

From a programming standpoint, when you set the bash shell to use vi or emacs via set -o vi or set -o emacs What is actually going on here? I ve been reading a book where it claims the bash shell ...

Dynamically building a command in bash

I am construcing a command in bash dynamically. This works fine: COMMAND="java myclass" ${COMMAND} Now I want to dynamically construct a command that redirectes the output: LOG=">> myfile.log ...

Perform OR on two hash outputs of sha1sum

I want perform sha1sum file1 and sha1sum file2 and perform bitwise OR operation with them using bash. Output should be printable i.e 53a23bc2e24d039 ... (160 bit) How can I do this? I know echo $(( ...

Set screen-title from shellscript

Is it possible to set the Screen Title using a shell script? I thought about something like sending the key commands ctrl+A shift-A Name enter I searched for about an hour on how to emulate ...