#!/bin/sh

scroll_top=1
scroll_bottom=15
scroll_count=4

i=1
while [ $i -le 24 ]
do
    printf 'line %2d ' $i
    j=0
    while [ $j -lt $i ]
    do
        printf '*'
        j=$(($j + 1))
    done
    printf '\n'
    i=$(($i + 1))
done

printf 'about to scroll %d-%d up by %d... ' $scroll_top $scroll_bottom $scroll_count
sleep 2

# set scroll region
printf "\e[${scroll_top};${scroll_bottom}r"

# move to first line of scroll region
printf "\e[${scroll_top};1H"

# scroll up
printf "\e[${scroll_count}M"

sleep 2

# clear scroll region
printf '\e[r'
