Reading Lines Into an Array
What is the safest way to get each line of hosts.txt into an array, one element per line?
hosts.txt
Choose one answer
hosts=$(cat hosts.txt)
read -a hosts < hosts.txt
hosts=($(cat hosts.txt))
mapfile -t hosts < hosts.txt