I'm trying to read a list of files from stdin, with each file delimited by a newline, however I'm noticing that only the first element is getting appended to the list. I noticed this by simply entering two strings and then q. Can anyone explain why?
files=()
read input
while [ "$input" != "q" ] ;
do
files+=( "$input" )
read input
done
for f in $files ;
do
echo "the list of files is:"
echo "$f"
echo "The length of files is ${#files} " #prints 1, even if 2+ are entered
done
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…