Search code examples
javacurlaemcrx

Delete file in linux server using curl command


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 ?


Solution

  • 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"