Rocking the blogosphere
Apple Online Store

A Bourne shell function for repeating a command

This is one of my favorite Bourne shell functions. It lets you repeat any command at a regular interval.

rept ()
{
    delay=$1;
    shift;
    while true; do
        eval "$@";
        sleep $delay;
    done
}

For example, if you want to monitor the size of a file as it’s downloading, you can use this to show it every 2 seconds.

rept 2 ls -l bootpage-20040921.zip

Very simple, but super useful.

Del.icio.us Digg Reddit Technorati

Possibly related posts

No comments yet. Be the first.

Leave a reply

Apple Online Store
Apple Online Store