1

I am trying to assign an array length to a variable.

servers=(apple orange)
len = ${#servers[@]}

it says len command not found. why?

1 Answer 1

4

You can't have spaces between your variable name and the assignment operator =. If you do it will treat the variable name as a command.

Try:

len=${#servers[@]}
Sign up to request clarification or add additional context in comments.

Comments

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.