/usr/bin/nnum is in stda 1.3.1-2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | #!/bin/sh
VERSION=2.2.2
NAME=`basename $0`
NV="$NAME $VERSION: print a series of integers, floats, or function values"
LICENSE="Copyright (C) 2006, 2007, 2009, 2011-2013 Dimitar Ivanov
License: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law."
################################################################################
ofmt="%.6g"
sep=`echo |awk '{printf( "%080d", 0 )}' |tr 0 -`
show_help()
{
cat << EOH && exit
$sep
$NV
$sep
Usage: $NAME <begin> <end> [<step>] [<func>] [<print_fmt>]
or: $NAME <number>
Examples:
a) $NAME 100
b) $NAME 10 1 -1
c) $NAME 1 10 0.1 x "N=%05.2f"
d) $NAME -3.14 3.14 0.01 "sin(x)" "sin(x)=%f at x=%f"
e) $NAME -3.14 3.14 0.01 "cos(x*x)" "%g %g"
Remark: an user-defined function should have syntax conforming to 'awk'.
EOH
}
show_version()
{
cat << !ver && exit
$NAME $VERSION
$LICENSE
!ver
}
case $1 in
-h|"") show_help
;;
--help) sep=""
NV="$NAME produces a series of integers, floats, or function values"
show_help
;;
--version) show_version
;;
-[-a-zA-Z]*) exec 1>&2
echo "$NAME: invalid option '$1'"
echo "Try \`$NAME -h' for help."
exit 2
;;
esac
case $# in
1) b=0; e=$1; d=1;
;;
2) b=$1; e=$2; d=1;
;;
3) b=$1; e=$2; d=$3;
;;
4) b=$1; e=$2; d=$3; func=$4;
;;
5) b=$1; e=$2; d=$3; func=$4; ofmt=$5;
;;
*) exit 1
;;
esac
[ "$func" ] || func=x;
sign=`echo $d \
|awk 'BEGIN { if( $1 == 0 ) exit }
{
if( $1 > 0 ) printf "+"
if( $1 < 0 ) printf "-"
}'
`
case $sign in
+) cop='<='
;;
-) cop='>='
;;
*) echo "($NAME) error: step must be different than zero"; exit 2
;;
esac
# Use e1 because of round-off errors with floating numbers
echo |awk "BEGIN \
{
CONVFMT = \"%.17g\"
OFMT = \"%.17g\"
e1 = $e + ($d/10)
}
MAIN
{
i = $b
while( i ${cop} e1 )
{
x = i;
printf( \"$ofmt\n\", $func, x )
i = i + ($d)
}
}"
|