Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

I am using csh.

Consider an array of arbitrary length:

set array = ( abc def ghi )

I have the following variable

set var = "def"

How can I find $var in $array and determine its index value?

I know I could come up with some elaborate loop where I string match each element and keep a running integer variable, $i, to determine the index value but I want to know if there is a more direct and compact way of doing this.

share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.