on-internet
← Community

BASH syntax for accessing an element of an associative array

Stack Overflow ·

I am giving my first steps in bash and would like to create a associative array and iterate it. My instinct would be to do this: declare -A FILES=(['SOURCE']='Source/Core/Core.js' ['DIST']='dist/Core.js') for file in "${!FILES[@]}"; do echo $file - $FILES[$file] done But output is: SOURCE - [SOURCE] DIST - [DIST] and no path as expected. What am I missing? and btw, is the declare -A required? Demo: https://ideone.com/iQpjmj Thank you

Comments

Sign in or sign up to comment and upvote.

No comments yet.