bash shell script variable assignment

后端 未结 1 1375
孤街浪徒
孤街浪徒 2020-12-12 05:30

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

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

it says len command not found. why?

1条回答
  •  长情又很酷
    2020-12-12 05:48

    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[@]}
    

    0 讨论(0)
提交回复
热议问题