rc-list - mailing list for the rc(1) shell
 help / color / mirror / Atom feed
From: culliton@srg.af.mil (Tom Culliton x2278)
To: cks@hawkwind.utcs.toronto.edu
Cc: rc@archone.tamu.edu
Subject: Re: how would you do this in rc
Date: Thu, 19 Dec 1991 19:27:02 -0600	[thread overview]
Message-ID: <9112192027.aa05620@ceres.srg.af.mil> (raw)

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
}


             reply	other threads:[~1991-12-20  1:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1991-12-20  1:27 Tom Culliton x2278 [this message]
  -- strict thread matches above, loose matches on Subject: below --
1991-12-20  0:09 Chris Siebenmann
1991-12-20  1:11 ` DaviD W. Sanderson
1991-12-20 12:21 ` David J. Fiander

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9112192027.aa05620@ceres.srg.af.mil \
    --to=culliton@srg.af.mil \
    --cc=cks@hawkwind.utcs.toronto.edu \
    --cc=rc@archone.tamu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).