Q: How to get lynx to recognize whitespace in filenames I'm using a script to find a list of all .pdf files on a url. But lynx seems to have a problem with spaces in filenames. Here's the script:
lynx --dump http://www.somesite/here/ | awk '/http/{print $2} | grep pdf > ~/Desktop/links.txt

This works as expected until there is a .pdf with whitespace in the filename. Lynx seems to truncate the filename at the whitespace. Is there some way to prevent this?

A: awk (by default) uses blanks as field-separators, and lynx is rendering a blank in a dumped url as a blank.  Work around it as I suggested in a bug report:

lynx -listonly -dump http://www.somesite/here/ | \
awk '/\.pdf$/{ sub("^[ ]*[0-9]+.[ ]*","",$0); print}' > ~/Desktop/links.txt

If the content happens to be in UTF-8 encoding, lynx unescapes the text (undoes URL-encoding such as %20), showing a blank in this case (making that two or more fields for awk, depending on the number of blanks in the name).
That unescaping was done for Debian #398274, in 2013 (i.e., you've got that feature with Ubuntu 18.04).
Adding the -listonly option reduces the number of incorrect matches, by looking only at the list of URLs.
If you wanted to look for multiple file-types, you could list the suffixes as alternatives in the regular expression, e.g., something like this:

awk '/\.(pdf|odt|doc|docx)$/{ sub("^[ ]*[0-9]+.[ ]*","",$0); print}' > ~/Desktop/links.txt

