Originally Posted by Last Attacker
while read url; do
--Do whatever here--
done < downloads.txt
That loop by itself does not add any newline characters to the data read into the url
variable. I think the newlines must be coming from something in the --Do whatever here--
If you need to remove newline characters from a string it can be done with the tr
Here is a sample data file.
foo$ cat movies.txt
Cthulhu Mansion (1992)
In the Mouth of Madness (1994)
As you can see the file contains three newline characters, one after each movie title. Now lets see what happens when we process the file with the tr
command from above.
foo$ tr -d '\n' < movies.txt
Re-Animator (1985)Cthulhu Mansion (1992)In the Mouth of Madness (1994)foo$
Now all the newlines have been removed. There are other ways, but this seems easy to me.
Be a little careful if you use this approach because utilities like awk
(for example) use newlines as record separators.
If this approach doesn't fit your needs then perhaps it would be helpful to review what else is going on inside your loop.