Search This Blog

Thursday, March 12, 2020

Bash and Arrays

Short reminder for my 'extended memory' on how to deal with lists in bash.

To define:
  • a list (an array): declare -a list
  • a dictionary (an associative array): declare -A dict
To use an array in loop: for item in ${list[@]}

Now the best, at least for scripts testing:
To print a whole array: declare -p list (please note, no "$" before list name).


Found at https://www.tutorialkart.com/bash-shell-scripting/bash-array/


No comments: