curl / Mailing Lists / curl-users / Single Mail
Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

Re: How to delete a file with '&' in its name on SFTP

From: Daniel Stenberg <>
Date: Fri, 3 May 2019 15:17:59 +0200 (CEST)

On Fri, 3 May 2019, Martijn Nabben wrote:

> C:\Progra~1\RipCurl\cURL\curl.exe -f --connect-timeout 10 --retry 1
> --retry-delay 30 -s -S -k -u "<uname>:<pword>" "sftp://<sftp
> site>/transfer/Waikato/blah.txt" -o "E:\<...>\Waikato\Download\blah.txt" -Q
> "-rm """/transfer/Waikato/blah.txt"" -w "%{size_download} bytes,
> %{time_total} ms"
> However when the file to be deleted contains an ampersand (&) the command
> fails with the following error:
> *curl: (21) Syntax error: Bad first parameter*

I'm not aware of any reason why '&' would be treated special for SFTP. Does
the Windows shell prompt do something special with it?

> 2) Replace & with %26 or \x26 - doesn't work.

I would expect '%26' to work exactly as '&'.

> We use curl version 7.23.1.

Wow, that's a mighty old version you're sporting. I would propose you at least
try this again with a modern version and see if there's any difference before
spending a lot of time on debugging it...

Received on 2019-05-03