summaryrefslogtreecommitdiff
path: root/seq
blob: 585087b8ec2049fefc3f5fe081530f3d654ff009 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# SYNOPSIS
#       seq [OPTION]... LAST
#       seq [OPTION]... FIRST LAST
#       seq [OPTION]... FIRST INCREMENT LAST

FIRST=1
INCREMENT=1

if [ $# -eq 3 ]; then
	FIRST=$1
	INCREMENT=$2
	LAST=$3
elif [ $# -eq 2 ]; then
	FIRST=$1
	LAST=$2;
elif [ $# -eq 1 ]; then
	LAST=$1
else
	printf 'use one of:\n'
	printf '\tseq LAST\n'
	printf '\tseq FIRST LAST\n'
	printf '\tseq FIRST INCREMENT LAST\n'
	exit 1
fi

i=$FIRST
while [ $i -lt $LAST ]; do
	printf '%d\n' $i
	i=$((i + INCREMENT))
done