6

I'm writing a shell script that needs to download some data from the Internet and I was just thinking if I can rely on cURL that it's pre-installed on all Unix distributions.
I know that wget is not on OS X by default but cURL is. I also remember me installing cURL on Ubuntu Server but it's already a year or two. I tried Ubuntu Server 12.04 today and it comes with cURL out of the box.

  • Tried it right now, Ubuntu Desktop 12.04 is not distributed with cURL. – martin Jun 14 '12 at 7:55
4

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.

| improve this answer | |
11

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

| improve this answer | |
  • 6
    Is there some kind of list available for each distribution with all pre-installed commands? – martin Jun 14 '12 at 7:24
2

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")
| improve this answer | |
0

It should be available for all major distributions, though not considered part of OS generally, and if it is not installed, any admin can install it. since it is opensource, even distros that don't have it can compile it. There is a windows port as well.

| improve this answer | |
0

It doesn't come with AIX. It's a pain in the butt to install on AIX, lots of dependencies.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.