0

I want to populate in array in chsell such that each index in the array will be an array itself. That is, if I ran

set a = ( `seq 1 2 10` )
set b = ( `seq 2 2 10` )
set array = ( $a $b )
echo $array[2]

then the return would be 2 4 6 8 10 (which is $b) instead of 3 (which is $a[2]).

Ultimately I could get away with declaring a bunch of variables, but it will make my code a mess. This would be similar to a cell in Matlab if that helps clarify the end result. Is there anyway to do this?

1 Answer 1

1

Csh doesn't have arrays, it only has lists of words, and is only a very limited programming language.

Given your constraints for a maintainable "clean" way of doing this in csh, the answer is no there is no solution.

This is very easy in a language such as Perl, which is designed for situations like this where the standard shells and UNIX utilities run out of steam.

Sign up to request clarification or add additional context in comments.

1 Comment

Luckily, I no longer work with the people who required Csh for scripting. Thanks for enlightening me to the exact limitations in this situation, though!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.