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 ${downloaded_file}
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:
war="/var/www/html"
targetUrl="https://releases.wikimedia.org/mediawiki/1.33/mediawiki-1.33.0.tar.gz"
fileName="${targetUrl##*/}"
wget "$targetUrl" -O "$war/$fileName" &&
tar -xzvf "$war/$fileName"
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:
war="/var/www/html"
domain="example.com"
targetUrl="https://releases.wikimedia.org/mediawiki/1.33/mediawiki-1.33.0.tar.gz"
wget "$targetUrl" -O "$war/$fileName" &&
tar -xzvf "$war/$fileName" --transform="s,^${targetUrl},${domain},"
I really doubt you do want these though. Why would https://releases.wikimedia.org/mediawiki/1.33/mediawiki-1.33.0.tar.gz
be part of the paths in the mediawiki-1.33.0.tar.gz
archive?
tar
to extract a file whose name is an URL. You want"$(basename "$downloaded_file")"
withtar
, or something similar. Also,tar
would have definitely given you an error message. – Kusalananda Aug 19 '19 at 15:56