From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from relay1.UU.NET ([137.39.1.5]) by archone.tamu.edu with SMTP id <18903>; Thu, 19 Dec 1991 19:39:15 -0600 Received: from uunet.uu.net (via LOCALHOST.UU.NET) by relay1.UU.NET with SMTP (5.61/UUNET-internet-primary) id AA13686; Thu, 19 Dec 91 20:39:05 -0500 Received: from srg.UUCP by uunet.uu.net with UUCP/RMAIL (queueing-rmail) id 203841.22722; Thu, 19 Dec 1991 20:38:41 EST Received: from ceres.srg.af.mil by srg.srg.af.mil id aa03969; Thu, 19 Dec 91 20:25:54 EST From: culliton@srg.af.mil (Tom Culliton x2278) X-Mailer: SCO System V Mail (version 3.2) To: cks@hawkwind.utcs.toronto.edu Subject: Re: how would you do this in rc Cc: rc@archone.tamu.edu Date: Thu, 19 Dec 1991 19:27:02 -0600 Message-Id: <9112192027.aa05620@ceres.srg.af.mil> Use awk. ;-) ;-) ;-) Anything else would involve shifting through a copy of the list and keeping a count with bc or something, or using bc to compute an index. This is just off the top of my head and hasn't been tested... # Invoked as: l=$mylist s=$mystring list_index # there is probably a MUCH better way fn list_index { # Is it even there? if (! ~ $l $s) { echo 0; return } # Go hunting for the first occurance cnt=1 while (! ~ $l($cnt) $s) { # This is a bit gross... cnt=`{ echo $cnt + 1 | bc } } # Tell 'em where we found it echo $cnt }