my code:
#!/usr/bin/bash
IFS=$'\n'; read -r -a item < "animals.txt"
declare -p item
animals.txt:
dog
cat
duck
bird
desired output:
declare -a item=([0]="dog" [1]=" cat" [2]=" duck" [3]=" bird")
what I get:
declare -a item=([0]="dog")
The Bash documentation says that if IFS is unset, then the default value will be <space>, <tab> and <newline>, but even if I remove the IFS=$'\n' from the code, it still doesn't work.