c shell get the ith+1 element of an array. eg array[i+1]

2.2k Views Asked by At

How do i get the value from echo $argv[$i + 1]?

I have tried

$argv[\` expr $i + 1 \`] 

but i get a Missing -. error

while ( $i <= $# )
    echo $argv[$i]
    echo $argv[$i + 1]
    set i = \` expr $i + 2 \
end
1

There are 1 best solutions below

0
On BEST ANSWER

You can't use arithmetic expressions inside brackets in csh, but you can use another variable:

while( $i < $# )
    echo $argv[$i]
    @ j = i + 1
    echo $argv[$j]
    @ i++
end