🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sources.d
Article #4996

Re: v06i100: Count program - leading zero enhancement

#4996
From: Wayne Thompson
Date: Tue, 16 May 1989 15:20
40 lines
1158 bytes
Here's a short script that does the same.

Wayne

#! /bin/sh
# output sequence of integers - W. Thompson - 01/29/88
#
USAGE='usage: num [-wWIDTH] [firstn] lastn.'

if [ $# -eq 0 ] || [ $# -gt 3 ]
then
	echo "$USAGE"
	exit
fi

for i
do case "$i" in
      -w[0-9])	WIDTH=`expr substr $i 3 1`;
                shift;;
      -*)	echo "$i illegal option";
                exit;;
      *)	break;;
   esac
done

if [ $# -eq 1 ]
then
	START=0
	END=$1
else
	START=$1
	END=$2
fi

awk '
	END {
		for (i = '$START'; i <= '$END'; i++)
			printf ("%0'$WIDTH'd\n", i)
	}
' /dev/null
Technical Details
Message-ID: <33795@mongo.uucp>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!lll-winken!ncis.tis.llnl.gov!helios.ee.lbl.gov!pasteur!ucbvax!decwrl!sun-barr!sun!mongo!waynet
References: <54804@uunet.UU.NET> <1989May16.000313.8145@tmsoft.uucp>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!lll-winken!ncis.tis.llnl.gov!helios.ee.lbl.gov!pasteur!ucbvax!decwrl!sun-barr!sun!mongo!waynet
From: waynet@mongo.uucp (Wayne Thompson)
Newsgroups: comp.sources.d
Subject: Re: v06i100: Count program - leading zero enhancement
Message-ID: <33795@mongo.uucp>
Date: 16 May 89 15:20:27 GMT
References: <54804@uunet.UU.NET> <1989May16.000313.8145@tmsoft.uucp>
Followup-To: comp.sources.d
Organization: Sun Microsystems, Inc. - Mtn View, CA
Lines: 40
In-reply-to: mason@tmsoft.uucp's message of 16 May 89 00:03:13 GMT