Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 15 Jun 1998 13:31:31 +1000
From:      Sue Blake <sue@welearn.com.au>
To:        Michael Richards <miker@scifair.acadiau.ca>
Cc:        Sue Blake <sue@welearn.com.au>, freebsd-questions@FreeBSD.ORG
Subject:   Re: what to learn?
Message-ID:  <19980615133131.11374@welearn.com.au>
In-Reply-To: <Pine.BSF.3.96.980614230123.8523A-100000@scifair.acadiau.ca>; from Michael Richards on Sun, Jun 14, 1998 at 11:10:35PM -0300
References:  <19980615085554.56310@welearn.com.au> <Pine.BSF.3.96.980614230123.8523A-100000@scifair.acadiau.ca>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, Jun 14, 1998 at 11:10:35PM -0300, Michael Richards wrote:
> On Mon, 15 Jun 1998, Sue Blake wrote:
> 
> > I have a large text file (2-3 megs) with numbers at the beginning of lines.
> > Currently I'm reading through this file, checking that the numbers go in
> > sequence, detecting errors but not fixing. This file has a long history of
> > cutting and pasting without always updating the codes properly :-(
> 
> So does this mean you want only to know where the errors lie, or you want
> to fix it?

No, just spot the error, then I tell the person who has to clean the muck
off the fan, and duck :-)

> My first approach would be simply to pipe it through sort.

I need to avoid sorting this file. I know the lines are in the correct
order, I'm not allowed to change that, I just need to know if the numbers
have been allocated stupidly. You see, the remainder of each line (after
white space) contains correct text and the lines are all in their final
order within the file. It's just the coding that might be be misleading if
the person who made up those numbers couldn't count.


> I have been known to do all kinds of wierd stuff with awk, and cut.
> 
> > ST71d-3.1
> > ST71d-3.2
> > ST71d-3.4   # whoops
> 
> I am not 100% clear on what you want to do, but a perl script may be
> easier than streams of text processors all iped together.
> 
> You could (in perl)
> load the file into an array.
> call sort to order it
> then mess with splitting the - number part off to make sure they don't
> skip any.

Yeah. It's the making sure they didn't skip any within the current sequence
of lines in the file that's the main thing I have to learn.

Sorting is out, it'd only remove some of the info I need to check. I suppose
basically I need to isolate the part of each line that I'm interested in,
then, within each group (a page or so), check that they are all alike except
for the number after the dot and that that number is the next one up from
what the previous line said. If it's a short one like ST71d-3 just check
that the part after the hyphen is bigger by one than the part after the
hyphen in the previous line. And quite a few more ifs and buts to take care
of in there.

If this is the wrong approach I don't really care, *that* is what I'm going
to work out when I start learning. RTFM is my sole aim here, not a solution
that'll get me through this one job, however tempting that is under the
circumstances. I just want to know whether to figure out how to do it while
using perl or cobol or named or fsck or some other obscure thing :-)

> Assuming of course this is what you wanted to do. There are a number of
> ways to attack this...

Thanks. Maybe this could be done with perl or awk or a dozen other things,
and none of them would do the job better than any other. In that case I
should be picking something to learn that'll be good for me to know about
later on, for other tasks.


-- 

Regards,
        -*Sue*-


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19980615133131.11374>