From mboxrd@z Thu Jan 1 00:00:00 1970 Received: by archone.tamu.edu id <18987>; Fri, 18 Oct 1991 14:31:36 -0500 From: Byron Rakitzis To: rc Subject: Re: how to drop the nth element of a list Message-Id: <91Oct18.143136cdt.18987@archone.tamu.edu> Date: Fri, 18 Oct 1991 14:31:31 -0500 You can do this in at most the cost of 3 forks and 2 execs; suppose that $foo contains the list you want to operate on, and $n contains the number of the element you wish to remove: foo=$foo(`{seq 1 $#foo | grep -v '^'$n'$'}) You could also probably do the stuff in backquotes in a single awk job, but it involves more messing around with quotes, and takes longer to type. Still, it will run faster: awk 'BEGIN{ for (i = 1; i < '$#foo'; i++) if (i != '$n') print i exit }' Packaging this into an rc function is left as an excercise for the reader...