In a Linux directory ~/Documents/Scratch, I've created the following tar file using the rethinkdb dump command:
kurt#kurt-ThinkPad:~/Documents/Scratch$ ls -tr | tail -n1
rethinkdb_dump_2016-10-10T16:58:32.tar.gz
However, if I try to untar this file, I get an "unexpected end of file" error:
kurt#kurt-ThinkPad:~/Documents/Scratch$ tar -zxvf rethinkdb_dump_2016-10-10T16:58:32.tar.gz
tar (child): Cannot connect to rethinkdb_dump_2016-10-10T16: resolve failed
gzip: stdin: unexpected end of file
tar: Child returned status 128
tar: Error is not recoverable: exiting now
Do I perhaps have to rename the file before unzipping it?
Yes you can rename it.
mv rethinkdb_dump_2016-10-10T16\:58\:32.tar.gz rethinkdb.tgz
tar zxvf rethinkdb.tgz
Or you can force it to look localy using --force-local:
tar -zxvf rethinkdb_dump_2016-10-10T16\:58\:32.tar.gz --force-local
Related
I can create a file file.tar.gz file from a directory directory using
tar -zcvf file.tar.gz directory
Unpacking it using
tar xzf file.tar.gz
recreates the directory directory. But how to create a file.tar.gz from the directory directory that creates directory-foo when unpacking with the same command (the unpack command needs to be kept)? Renaming the directory directory to directory-foo before packing should be avoided as well as duplicating the directory.
When trying the suggested
OLDNAME=directory
NEWNAME=directory-foo
tar --transform='s,$OLDNAME/,$NEWNAME/,' -x -f file.tar.gz
I'm getting
tar: Option --transform=s,$OLDNAME/,$NEWNAME/, is not supported
Usage:
...
Tar admits a sed expression to modify file names. You may use --transform or --xform.
How to create an empty tgz file?
I tried
tar czvf /tmp/empty.tgz --from-file /dev/null
tar: Option --from-file is not supported
The switch you're looking for is --files-from or -T:
tar czvf /tmp/empty.tgz --files-from=/dev/null
My tex file used to be utf-8.
When I tried to compress it to send to others, I accidentally tar the file twice using
tar -xf litreview.tex figure/
tar -cf litreview.tex figure/
(figure/ is the directory where I store my figs for the .tex)
and my .tex became a binary file
Master:LitReview ning$ file litreview.tex
litreview.tex: POSIX tar archive
When I tried to untar it, I received
Master:LitReview ning$ tar -xvf litreview.tex
tar: Damaged tar archive
tar: Retrying...
tar: Damaged tar archive
tar: Retrying...
Any chance to convert it back to tex?
ssh user#server "sudo tar -czf - -C /path/To/Directory *.properties" | tar xzf -
It fails with following error -
tar: *.properties: Cannot stat: No such file or directory
tar: Exiting with failure status due to previous errors
If I ssh to server and then on server, instead of tar -czf - use tar -czf abc.tgz and remove the piped command at the end, it works correctly i.e. compress all the .properties file from the directory?
I have tried using --wildcards parameter as well as -P and the complete path ending with *.properties, but they didn't work either.
The shell at the far end expands *.properties in user's home directory, before it execs tar. I'm guessing there's no matching files in ~user.
What you probably want is something more like (assuming user can access the directory)
ssh user#server 'cd /path/To/Directory && sudo tar -czf - *.properties' \
| tar xzf -
Or, use tar's --wildcards option, and stop the remote shell expanding the argument:
ssh user#server 'sudo tar -czf - -C /path/To/Directory --wildcards \*.properties'
I am trying extract .tar.gz file it but with no luck
gzip: stdin: unexpected end of file
tar: Unexpected EOF in archive
tar: Unexpected EOF in archive
tar: Error is not recoverable: exiting now
the file tar.gz include another file.tar only which is has the issue
when i trying to extract .tar file i got
tar: Unexpected EOF in archive
tar: Unexpected EOF in archive
tar: Error is not recoverable: exiting now
i tried –ignore-zeros –ignore-failed-read with no luck
how could i extract this file even if it corrupted ?
You tar file is truncated. tar extracts everything present in the archive but cannot invent the missing part.