Automation, Orchestration, and Scripting

A script must loop over each directory in $PATH, treating every directory as a separate array element. Which command builds that array?

Show the answer

Correct answerA. IFS=: read -ra dirs <<< "$PATH"

IFS=: makes read split on colons, and -a stores each field as an array element. Without -a, a single variable receives the whole string. Without IFS=:, the default whitespace splitting finds no separators in PATH, so the array has one element.