5
wget https://some.url/with/a/file.txt

Returns No such file or directory despite file.txt being present at the location (can be downloaded via browser). Also the directory to save to is writeable by the user running the command.

steros
  • 1,794
  • 2
  • 26
  • 60
  • StackOverflow is dedicated to helping solve programming code problems. Your Q **may be** more appropriate for [su] , but read their help section regarding on-topic questions . AND please read [Help On-topic](https://stackoverflow.com/Help/On-topic) and [Help How-to-ask](https://stackoverflow.com/Help/How-to-ask) before posting more Qs here. Good luck. – shellter Jul 08 '20 at 00:10
  • Does this answer your question? [Are shell scripts sensitive to encoding and line endings?](https://stackoverflow.com/questions/39527571/are-shell-scripts-sensitive-to-encoding-and-line-endings) – tripleee Feb 01 '22 at 06:24

3 Answers3

22

There are a lot of related threads but nothing helped.

Finally found out there is an illegal character in front of the url!

That was so hard to find I post it here in case anyone stumbles upon the same.

steros
  • 1,794
  • 2
  • 26
  • 60
  • 1
    Care to elaborate? What was the illegal character? – Eric Wolf Dec 04 '20 at 02:59
  • 2
    Sorry I only remember it wasn't "visible" so I think it must have been U+FEFF or one of these: U+200B, U+200C, U+200D, U+200E,U+200F. – steros Dec 08 '20 at 13:05
  • 2
    This happened to me copying the curl command from another application to the terminal. At the terminal prompt I had to delete the spaces and re-insert them for it to work. Thank you for the suggestion. – vegemite4me Mar 23 '21 at 12:10
  • Just ran into this trying to install lgpio...cut and paste from their website example (even though it looked like it was in a code box). Delete the space between wget and the URL and replace...boom works fine. Took me too long to find this solution, so thank you Steros 3 years later. – evildemonic Feb 13 '23 at 21:56
0

Close the terminal and try again to run the script.

0

Stumbled upon this with a similar issue using curl. The root cause for me was curl was unable to find the destination directory.

adding --create-dirs to the command will ask curl to create the directories if they do not exist, which solved my issue.

eg.

# I want to download this file to ~/development/csvs/saved_file.csv
# Assume I am executing from a ~/development/ directory, which has no csv dir

# this will not work
curl 'https://bla.com/cool_csv.csv' > csvs/saved_file.csv

# this will work
curl 'https://bla.com/cool_csv.csv' -o csvs/saved_file.csv --create-dirs

-o will replace > and will specify output

reference question

SenatorWaffles
  • 311
  • 2
  • 7