MLUG: Re: [MLUG] a little fun thing...
Re: [MLUG] a little fun thing...
Email address obfuscation in effect -- please click here to turn it off.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
On Wed, 6 Jul 2005, Jonathan King wrote:

On 7/6/05, Stephen Montgomery-Smith <EMAIL:PROTECTED> wrote:

seq is also not a standard part of FreeBSD.

Yup, and (therefore?) it's not a standard part of Mac OS X, on which I was running the example. (I see what the pipeline is supposed to do, of course. :-))

My apologies to the FreeBSDers and the MacOSXers, but this is a Linux list, after all, and we are therefore not obliged to accomodate you! ;-)


I want to be accomodating anyway, so I'll share a perl script that I found a few years ago. I call it "perlseq" on my system, but the authors called it "seq". It is only 52 lines and less than 1 KB and it is attached to this message. It can do both numbers and letters, while ordinary 'seq' does only numbers. Ah, nice ... I just found it on the 'net here:

http://alumnus.caltech.edu/~copeland/work/lottery.html

Once you get that running, you can do this...

perlseq 10000000 | perl -pe 's/\n/\r/'

...or this:

perlseq 100 | perl -pe 's/\n/\r/' | less

What fun!  ;-)

Mike
#!/usr/bin/perl -w
# $Id: seq,v 1.1 1999/11/27 00:05:43 jsh Exp $

use strict;

my $usage = "usage: $0 [start] end" unless @ARGV == 2;
unshift @ARGV, 1 if @ARGV == 1;
die $usage unless (@ARGV == 2);

foreach ($ARGV[0]..$ARGV[1]) {
    print "$_\n";
}

=head1 NAME

    seq - print a sequence

=head1 SYNOPSIS

    seq [start] end

=head1 DESCRIPTION

C<seq> generates sequential integers

By default, it starts counting at 1. 
For example,

    $ seq 3 5
    3
    4
    5

=head1 BUGS

By little more than a lucky accident,
C<seq>
does odd, sometimes useful things
with non-integer arguments.
Not obvious that this is a bug.
Try this, for example:

    $ seq cat dog

=head1 AUTHORS

Just a re-implementation of something used
in Kernighan and Pike, but never written in there.
Maybe it's part of Plan 9 or something.

    Dan Crawl <EMAIL:PROTECTED>
    Jeffrey S. Haemer <EMAIL:PROTECTED>
_______________________________________________
members mailing list
EMAIL:PROTECTED
http://mlug.missouri.edu/mailman/listinfo/members