I have 3 lines in file /root/backuplist.txt
.
The first echo
prints perfectly, but the last one prints an empty line; I'm not sure why. Somehow, the $DIRS
value is getting unset.
#!/bin/bash
cat /root/backuplist.txt |
while read line
do
DIRS+="$line "
echo $DIRS
done
echo $DIRS