Extracting .tar file isn't working

2019-04-07 06:52发布

问题:

Thanks ahead of time for all your help guys! As a beginner user I really appreciate the help!


My Machine/OS: Mac OSX 10.5.8, 32-bit


What I'm trying to do: Extract and install Apache Maven, from the website.


What I've done: Downloaded the binary .tar.gz file from the website, and using the shell, moved the downloaded file to the appropariate directory, and extracted the .tar out of the .tar.gz by using gunzip -v filename.tar.gz, resulting a .tar file. Now I'm trying to extract the .tar file using tar -xv filename.tar.


My Problem The extraction doesn't seem to be working! After I've typed the tar -xv filename.tar command and hit enter, the shell isn't returning any output, and doesn't seem to complete the extraction. It stays indefinitely with the empty line returned after hitting enter.


My Attempts Examining the directory from another Shell window, both while tar is running and after quitting the shell while the process is running, doesn't show any changes in the files contained; i.e. the only file/directory present is the original .tar.gz file. I've also tried deleting the file along with the directory containing it, re-creating the directory, re-copying the file into the directory, and then re-trying the tar -xv filename.tar command. The result is the same


Thank you so much everyone!

回答1:

try the following command:

tar -xzvf filename.tar.gz


回答2:

sudo tar -xvf filename.tar

This fixes two problems with the above tar -xv filename.tar.

1st Issue: Needed to include a the -f modifier for tar. Per [lowfatlinux][2], -f is a command for tar that says:

"The archive file name is given on the command line (required whenever the tar output is going to a file)"

Therefore, including the -f modifier tells the tar program that the file name supplied in the arguments is the file to extract from.

2nd Issue: Needed to append sudo to the beginning of the command, to give the shell permission to create directories



回答3:

Try the following command:

gunzip -c filename.tar.gz | tar xopf -

After you tried gunzip, use tar xopf on that file

tar xopf filename.tar


回答4:

Your download was most likely corrupted, notice what it says on the website:

NOTE Following links will list to you various available mirrors. DO NOT USE those links directly.

This mirror worked for me on Debian:

wget http://www.us.apache.org/dist/maven/binaries/apache-maven-3.0.4-bin.tar.gz
tar -xvzf apache-maven-3.0.4-bin.tar.gz