开发者

how to send/echo x (specific) number of messages in a shell script per sec

How can I send some specific number of, say 1000, messa开发者_JAVA百科ges (echo) per second to a file by a shell script?

i.e. I want to echo 1000 such messages ("hi") per sec to a (tmp) file. echo "hi" >> tmp


Best you can do is this:

while :; do
    i=0
    while [ $i -lt 1000 ]; do
            echo hi >> tmp
            i=$((i+1))
    done
    sleep 1
done

The time to actually execute the commands in the inner while loop is not taken into account, so this will write slightly less messages per second.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜