Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

2
  • 1
    Just to add more information to @Janis answer, if your run the script with bash -x students.sh you will see that the last read will increment in 1 the array: + read 'students[11]' + echo 11 11 + ArrayLength=12. Since it's reading the 11th position, the ArrayLength will be 12 at the end of the operations. Commented Mar 5, 2015 at 19:01
  • Note that read fails when it doesn't read a newline character. It may fail and assign a non-empty string if the input ends in a non-terminated line. Like in printf foo | read line. Commented Mar 9, 2015 at 14:38