Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Post History
Your code adds all three elements to the list. You can see this if you add a line inside the while loop: echo "$line" However, if you give the command echo $my_array, it will only show you the...
Answer
#1: Initial revision
Your code adds all three elements to the list. You can see this if you add a line inside the `while` loop: echo "$line" However, if you give the command `echo $my_array`, it will only show you the first element. (I'm not yet sure why, because I don't do a lot of shell scripting. I'll edit this answer once I find out. I've got a feeling it's supposed to work this way). To show the entire array, you need `declare -p my_array`, or write another loop that lists all the elements. Source used: https://www.tutorialkart.com/bash-shell-scripting/bash-array/