Categories
BLOG

tar pipe

Piping of stream from wget to tar, and extracting it to a specific location failed

I try to pipe a stream from wget to tar and extracting it to a specific location.
The file is downloaded by wget but not extracted as desired with tar:

Why piping of stream from wget to tar, and extracting it to a specific location failed?

3 Answers 3

You can combine both commands and skip writing a file by instructing wget to write to its standard output:

This will cause tar ’s output to be mixed with wget ’s progress indicator, because it will start extracting the tarball while wget is still downloading it, so you may well want to adjust the output options.

You can use tar ’s -C option to control where the files are extracted:

The target directory needs to exist before the command is run, so mkdir it if necessary first.

You’re writing the downloaded data to a file, so you’re not actually piping anything to tar . Pipes are only useful if you want the standard output of one program to become the standard input of another. Here, you are downloading a file and then want to open it with another tool, so pipes aren’t useful.

The next issue is that your $downloaded_file is actually a URL. So when you tar -xzvf $ you’re actually running tar -xzvf https://releases.wikimedia.org/mediawiki/1.33/mediawiki-1.33.0.tar.gz and that will fail since that file doesn’t exist (it’s not a file, it’s an internet address).

What you want to do is something like this:

I don’t see why the -P option of wget would be relevant here, nor why you would need the –transform from tar , but if you must use it, you can do:

Piping of stream from wget to tar, and extracting it to a specific location failed I try to pipe a stream from wget to tar and extracting it to a specific location. The file is downloaded by