wget output conflicting options

I was trying to download some image with wget and set both a name and directory for its output. Reading the wget man page, it shows different options to deal with each one of the situations, -O to set the downloaded file’s name and -P to set its directory.

Anyway, if you try to use both one there is a kind of overwriting options. Let’s try the following example to realize this unexpected behavior, at least in my opinion:

I want to download the Google’s logo with a customized name “downloaded.gif” and also want that the output file to be take to /tmp directory. So, the following command should do the work:

wget http://www.google.com.br/intl/en/images/logo.gif -P /tmp -O downloaded.gif

What we have here is, wget (google logo) -P (the directory where I want the downloaded logo output) -O (the name of the output file). But the resulting file “downloaded.gif” goes to ‘.‘ directory. It seems that the default output directory did not change even when using the -P parameter. The parameters order does not matter, i.e., the following command does the same unwanted thing:

wget http://www.google.com.br/intl/en/images/logo.gif -O downloaded.gif -P /tmp

To solve this problem I did forget the -P parameter, and used just the -O writing together both the output directory and file name. So, the following command solved my problem:

wget http://www.google.com.br/intl/en/images/logo.gif -O /tmp/downloaded.gif

One Response to wget output conflicting options

  1. Jim says:

    Thank you so much. I was getting frustrated by the same problem!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: