From: Ed Morton Date: 2011-05-20T08:20:29+09:00 Subject: Re: Linux utility with reverse index facility? On May 17, 10:40 pm, Robert Nichols wrote: > On 05/16/2011 05:38 AM, no.top.p...@gmail.com wrote: > > > awk&stuff can "give me the the Nth element", > > but, without writing your own search-loop, > > what can "give me the index of the 'element' > > which is" ? > > > I think it's called 'reverse indexing' ? > > In awk, it's just as easy to build an array where your "elementValues" > are the indices and the values stored in the array are ordinal numbers. > I,e., instead of >      myArray[n++] = "cheese" > have >      myArray["cheese"] = n++ > > Now you can use myArray["something"] in an expression and get back > the number that was stored for that string (or a null string equivalent > to arithmetic 0 if that index was never stored). > > -- > Bob Nichols         AT comcast.net I am "RNichols42" not really robust though. consider what would happen if the same string appeared twice in a record.