blob: 9721432d6511a432180217e6e59671790e5bf243 (
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
31
32
33
|
#!/bin/sh
if [ $# -ne 3 ]; then
echo "Usage: ./seq.sh FIRST INCREMENT LAST" 1>&2
exit 1
fi
if [ "$2" -eq 0 ]; then
exit 1
fi
if [ "$1" -eq "$3" ]; then
echo "$1"
exit 0
fi
if [ "$1" -lt "$3" ]; then
[ 0 -gt "$2" ] && exit 1
i="$1"
while [ "$3" -ge "$i" ]; do
echo "$i"
i=$(($i + $2))
done
exit 0
fi
[ "$2" -gt 0 ] && exit 1
i="$1"
while [ "$i" -ge "$3" ]; do
echo "$i"
i=$(($i + $2))
done
exit 0
|