Monday, July 25, 2022

[SOLVED] Getting a file with hash (#) in path by curl

Issue

I want to use curl (v 7.22.0) to download some files from a server, where they name directories like report#1, report#2, etc. So i tried...

curl sftp://sftp.example.com/report#1/main.png -u login:pass -o tmp.txt

...but curl gives me "no such file or directory". It probably thinks the hash is a fragment identifier (e. g. web page anchor) and therefore looks at URL sftp://sftp.example.com/report instead.

Is there a way how to escape a hash sign, so it is recognized as a part of file path? (Quoting/escaping doesn't help.)


Solution

Try this:

Replace in URL # with %23.



Answered By - Cyrus
Answer Checked By - Robin (WPSolving Admin)