tar
To extract an archive to a directory different from the current one, use the -C, or --directory, tar option
tar -xf archive.tar -C /target/directory
to extract an zip fomate archive, use this command:
tar -zxvf archive.tar -C /target/directory
Sometimes compressed files are not what they look from the extension. Recently I downloaded a .tar.gz file (say, we call it as filename.tar.gz) but when I tried to extract it, it gave error. It went something like this:
tar: This does not look like a tar archive
The error says it all. This does not look like a tar archive. What does it look like than? The way to find it out is using file
command in the following manner:
file filename.tar.gz
I got:
filename.tar.gz: HTML document, ASCII text, with CRLF line terminators
How can it be a html file?
I cat
the file and got this:
<html>
<head><title>404 Not Found</title></head>
<body bgcolor="white">
<center><h1>404 Not Found</h1></center>
<hr><center>nginx/1.10.0</center>
</body>
</html>
That's it.