I wrote this script to get some files off a webcam server. The files, are all downloaded, but when I was running the script, the last line never ends, even after the file was downloaded. So, I would like to know why. Why did this script never terminate? The wget command got the last file, but did not exit.

while read line
do z=$(($z+1));
echo $x${line//};
wget $x${line//};
done < "/home/jay/Desktop/PINGS"

So why doesn't this script terminate?

1 Answer 1


The last line contains just read.

Read the help page of read, from help read:

Read a line from the standard input and split it into fields.

So unless you give input to read via STDIN, it will be blocked indefinitely.

In a script, read is normally used to read lines(s) from file(s) or to take user input (like your case).

  • I totally spaced out on that. thanks for pointing it out.
    – j0h
    Dec 15, 2015 at 13:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .