shellcurlassembla

Use CURL Command to download remote files in Shell scripting


I need to download remote files using curl command below

curl -O -J "URL"

This is working as expected when I use this command separately when I try to use the same command in a shell script(below). it gives error below.

#!/bin/bash 
$curl -O -J "$url_final"
=======================================================
"curl: (3) URL using bad/illegal format or missing URL"

Solution

  • Using a valid url in my tests seemed to have no issues with this curl request. I also tried using with and without wrapping the url in a string like you are along with using brackets.

    url="https://cdn.sstatic.net/Sites/stackoverflow/img/sprites.svg?v=1b3cdae197be"
    
    # all work fine
    curl -O -J $url 
    curl -O -J "$url"
    curl -O -J "{$url}"
    

    My best answer is that your $url_final variable is undefined, empty, or malformed.