-11

I want to delete a file I saved in the linux server using curl command. Basically trying to achieve "rm -rf /myfolder/myFile.zip" using curl.

I tried this command. curl -X DELETE /myfolder/myFile.zip

But it throws an error : curl: (3) <url> malformed

I will ultimately need to run this via a java class, but for now, just trying to run it directly in linux to verify.

Am I missing some syntax here ? How can I provide a full url when I AM inside the very server ?

Riju Mahna
  • 6,718
  • 12
  • 52
  • 91
  • 1
    Why do you want to use curl? Why even use a system command at all, when you have [Files.delete](https://docs.oracle.com/javase/10/docs/api/java/nio/file/Files.html#delete(java.nio.file.Path))? – VGR Jun 08 '18 at 14:23
  • @VGR - Thanks. I just tried to go with curl because I downloaded my file to this location using curl, and now I wanted to delete it. Will give the files API a try for this. – Riju Mahna Jun 08 '18 at 15:09

1 Answers1

1

Curl is used for sending HTTP requests. Maybe you want to issue the rm command via ssh?

From this stackexchange question:

ssh hostname "rm /myfolder/myFile.zip"

chrylis -cautiouslyoptimistic-
  • 75,269
  • 21
  • 115
  • 152
Freggar
  • 1,049
  • 1
  • 11
  • 24