How to tar a directory - python-3.x

I want to tar two directories I have downloaded into my program. I am working in Colab environment similar to tensorflow. But when i run the following commands
!tar -zxf ./RoadDamageDataset.tar.gz
!tar -zxf ./trainedModels.tar.gz
I get this type of error
gzip: stdin: unexpected end of file
tar: Unexpected EOF in archive
tar: Unexpected EOF in archive
tar: Error is not recoverable: exiting now
So far I have tried to run the above commands without - but it doesn't work.
Also somewhere I have read that maybe the files are not downloaded properly so I have double checked the files and again downloaded for two times but still this error remains.
Can anyone here help me with this kind of problem as I have no idea with how to deal with tar.
Thank you

Related

opening tar file displays "This does not look like a tar archive"

I have downloaded some data from the internet and the files come with this format
file.pth.tar
when I am trying to open it through cygwin terminal it says:
tar: This does not look like a tar archive
tar: Skipping to next header
tar: Exiting with failure status due to previous errors
I tried to open it in windows but it says
Invalid archive open/read error
I tried to find the file type using: file full_graph.pth.tar
and it displays:
full_graph.pth.tar: data

Gitlab backup restore Error --> tar: This does not look like a tar archive

I am trying to restore GitLab (8.16.1) backup on Ubuntu server (backup taken by command sudo gitlab-rake gitlab:backup:create) using command:
sudo gitlab-rake gitlab:backup:restore BACKUP=1493107454_2018_04_25_10.6.4-ce
Its giving me error:
gzip: stdin: not in gzip format
tar: This does not look like a tar archive
tar: Exiting with failure status due to previous errors
my Backup file is .tar file.
gzip version 1.6
As of my knowledge before it restore that backup file it first extract.
I don't know why that extracted files are having extension .tar.gz.
Can anyone help with this ?
sudo gitlab-rake gitlab:backup:restore BACKUP=1493107454_2018_04_25_10.6.4-ce
That means you should have a file like:
var/opt/gitlab/backups/1493107454_2018_04_25_10.6.4-ce_gitlab_backup.tar
And a cat backup_information.yml in that same folder giving you information about that backup.
If the file is not a valid archive, that would explain the error message.
You can add --trace to the rake command to know more.

cygwin extracting to another directory

I have a file, in Windows, called php_0.27.tar.gz and want to extract it to C:\Program Files\PHP\script through Cygwin using this command:
tar -xf php_0.27.tar.gz -C /Program Files/PHP/script
But I got an error saying:
tar: Files: Not found in archive
I tried this command too:
tar -xf php_.tar.gz --directory /Program Files/PHP/script
But I got an other error saying:
tar: php_0.27.tar.gz: Cannot open: No such file or directory
So I tried:
tar -xf php_.tar.gz --directory C:/Program Files/PHP/script
But I failed and now I am stuck. I need help
The space in the directory name Program Files is the source of the error ; putting the whole path to directory between quotes like this "C:/Program Files/PHP/script" solve the problem

How tar xvfz works in cygwin?

I tried tar with xvfz and -xvfc both didn't work in Cygwin on Windows.
$ tar xvfz sshpass-1.0.5.tar.gz
tar (child): sshpass-1.0.5.tar.gz: Cannot open: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
Here cmd tar with '-'
$ tar -xvfz sshpass-1.0.5.tar.gz
tar: z: Cannot open: No such file or directory
tar: Error is not recoverable: exiting now
Question :
1 . How does tar works with - or without _ ?
Please suggest to execute tar -xvfz sshpass-1.0.5.tar.gz.
tar has 3 types of syntax (according to this ):
long options (--file)
short options (-f)
old options (f)
For the old option syntax, all the letters must follow "tar" and must all fall into a single clump with no spaces. The order of the letters doesn't really matter, so long as the arguments to those letters follow the same order after the clump of options.
This old way of writing tar options can surprise even experienced users. For example, the two commands:
# tar cfz sshpass-1.0.5.tar.gz file
# tar -cfz sshpass-1.0.5.tar.gz file
are quite different. The first example uses ‘sshpass-1.0.5.tar.gz’ as the value for option ‘f’ and recognizes the option ‘z’. The second example, however, uses ‘z’ as the value for option ‘f’ — probably not what was intended.
Old options are kept for compatibility with old versions of tar.
The command with a '-' is equivalent to
tar -czf sshpass-1.0.5.tar.gz file
tar -cf sshpass-1.0.5.tar.gz -z file
tar cf sshpass-1.0.5.tar.gz -z file
Got it, there was a typo error for in file name, corrected and ran. it worked.
$ tar xvfz sshpass-1.05.tar.gz
sshpass-1.05/
sshpass-1.05/COPYING
sshpass-1.05/AUTHORS
sshpass-1.05/aclocal.m4
sshpass-1.05/INSTALL
sshpass-1.05/Makefile.am
sshpass-1.05/configure.ac
sshpass-1.05/install-sh
sshpass-1.05/Makefile.in
sshpass-1.05/sshpass.1
sshpass-1.05/configure
sshpass-1.05/depcomp
sshpass-1.05/README
sshpass-1.05/NEWS
sshpass-1.05/config.h.in
sshpass-1.05/missing
sshpass-1.05/main.c
sshpass-1.05/ChangeLog

How to extract this .tgz file in cygwin

I have install cygwin and want to install a tgz file. I typed following command:
$tar xvfz tidy_src.tgz
Error occurs:
gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Error is not recoverable: exiting now
Then I type following command to check;
$file tidy_src.tgz
It shows it's a ASCII text
So I continue type:
$tar xvf tidy_src.tgz
Still doesn't work.
Anyone can give some help?
You can download this free-virus file at http://tidy.sourceforge.net/src/tidy_src.tgz
untarring a gzipped file that you have made yourself from known content with the same command.
if that works then you confirm that the archive is corrupt.

Resources