Pectus Excavatum
Pectus Excavatum

Reputation: 3785

Shell Bash declaring an array

I am having some issues declaring an array in Bash.

I am trying to use declare -A props

But it gives me an error that states:

  declare -A: invalid option           
  declare: usage: declare [-afFirtx] [-p] [name[=value]] ...]

Any help would be greatly appreciated as the array is currently 0.

I am trying to create an array that stores a key and a value.

Upvotes: 0

Views: 495

Answers (1)

Ken
Ken

Reputation: 8917

Associative arrays are declared using declare -A. Indexed arrays are declared using declare -a.

If you need the former, check your version of bash bash --version since they were introduced in bash 4.0.

Upvotes: 9

Related Questions