#!/bin/sh
# lnextract.sh
#       extract part of a file between a
#       line numbers $1 and $2

function isnum () {
	case "$1" in
	*[^0-9]*)
		return 1;;
	esac
	}

[ "$#" -gt "2" ] || {
	echo "Must supply begin and end line numbers" >&2
	exit 1
	}

isnum "$1" || {
	echo "first argument (first line) must be a whole number" >&2
	exit 1
	}

isnum "$2" || {
	echo "second argument (last line) must be a whole number" >&2
	exit 1
	}

begin=$1
end=$2

[ "$begin" -le "$end" ] || {
	echo "begin must be less than or equal to end" >&2
	exit 1
	}

shift 2
for i; do
[ -r "$i" -a -f "$i" ] || {
		echo "$i should be an existing regular file" >&2
		continue
		}
ln=0
while read a ; do
	let ln+=1
	[ "$ln" -ge "$begin" ] && echo $a
	[ "$ln" -lt "$end" ]   || break
	done < "$i"
done
exit 0
