Is cURL standard part of all Unix-like operating systems?

Solution 1:

No, cURL is not a standard part of operating systems. It isn't ever standard on all Linux based distributions.

Solution 2:

Everything else equals I would say it being more likely that you have wget installed.

Yet, why not simply make a conditional, looking for both wget and curl in the PATH, and use whatever is available, if any? If you want to be ambitious, also feel free to through in lynx, w3m, etc in the mix.


Solution 3:

Since some machines tend to have curl and others tend to have wget pre-installed, I sometimes use this in Bash scripts :

# use curl or wget, depending on which one we find
curl_or_wget=$(if hash curl 2>/dev/null; then echo "curl -s"; elif hash wget 2>/dev/null; then echo "wget -qO-"; fi);

if [ -z "$curl_or_wget" ]; then
        echo "Neither curl nor wget found. Cannot use http method." >&2
        exit 1
fi

x=$($curl_or_wget "$url")

Tags:

Unix

Curl