I am trying to assign an array length to a variable.
servers=(apple orange) len = ${#servers[@]}
it says len command not found. why?
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[@]}
2.1m questions
2.1m answers
60 comments
57.0k users