I want to zip all .txt files in using zip command in linux recursively. For this, I'm using:
zip -r /home/folder/zipName /home/folder2/subfolder1/*.txt
and it is giving me the below error:
zip warning: missing end signature--probably not a zip file (did you
zip warning: remember to use binary mode when you transferred it?)
zip warning: (if you are trying to read a damaged archive try -F)
zip error: Zip file structure invalid
use
zip -r /home/folder/zipName /home/folder2/subfolder1 -i \*.txt
it will do what you expected.
I had the same error, and I found that the solution was to make sure that your zipName ends in .zip. Putting this here in case it can help somebody else.
This works for me ...
zip -r /home/folder/zipName /home/folder2/subfolder1/**/*.txt
Related
in Python I have the following command executed unzip '{dir}ATTOM_RECORDER/*.zip' -d {dir}ATTOM_RECORDER/ as a bash command. The python call works perfectly. my question is about the unzip command itself.
for some reason when unzip is called to expand any relevent zip files in the folder specified, not all the files WITHIN the zip is extracted. There's usually a rpt and a txt file. However, sometimes the txt file is not coming out and I do not have an error command.
How can I ensure the txt file is guaranteed to be extracted before moving on?
Thanks
While you want to unzip your specific zip file. There are many option to decompress any file from zip files. Easiest way is the ā-lā option with unzip command is used to list the contents of a zip file after extracting it.
Syntax: unzip -l [file_name.zip]
So i have a folder structure like MyFolder/File1, MyFolder/File2 .... MyFolder/FileN
I want to zip all the contents of MyFolder to MyFolder.zip such that on unzipping MyFolder.zip the contents are File1, File2 ... FileN
I want to do this using the linux command line.
I saw a method using the -r option of the zip command but the issue is that it creates a MyFolder.zip that on unzipping gives MyFolder. I do not want the MyFolder in it. I want it to directly give me the contents of MyFolder.
Any help will be appreciated. Thanks
You might enter the directory first before running the zip command (output file should be elsewhere for speed & to avoid warning "file changed during compression" on the zip file itself
zip ../toto.zip . -r
for example
Example:
Here's list of files in "/tmp/test_dir"
file1
zip -r Test_Files.zip *
When I unzip Test_Files.zip I'm getting the below output
Current working directory "/tmp/test_dir"
/tmp/test_dir/file1
What I'm expecting when I unzip Test_Files.zip;
/tmp/test_dir/Test_Files/file1
Can anyone help how do i get expected result as mentioned above?
Use unzip. You can use -o to overwrite the existing files and -q to make it quiet. In doubt? Just use terminal and type in unzip (or try /usr/bin/unzip) to see helpful information.
1) extract from large zip file
I want to extract files from a large zip file (30Gb+) on the linux server. There is enough free disk space.
I've tried jar xf dataset.zip. However, there's an error that push button is full, and it failed to extract all of the files.
I tried unzip, but zipfile corrupt.
Archive: dataset.zip
warning [dataset.zip]: 35141564204 extra bytes at beginning or within zipfile
(attempting to process anyway)
error [dataset.zip]: start of central directory not found;
zipfile corrupt.
(please check that you have transferred or created the zipfile in the
appropriate BINARY mode and that you have compiled UnZip properly)
I tried zip -FF dataset.zip --out data.zip, and there's an error that entry too big:
zip error: Entry too big to split, read, or write (Poor compression resulted in unexpectedly large entry - try -fz)
Is there anyway I can efficiently extract files from really large zip file?
2) extract certain files from a large zip file
If I only want some certain files from this large zip file, is there anyway I can extract only these files? For example, data1.txt from dataset.zip? It seems that I can't use any zip or unzip command (always have the zipfile corrupt problem).
Thanks!
I've solved the problem. It turns out to be a zip corruption problem. I first fixed the file with:
zip -FF filename1.zip --out filename2.zip -fz
then unzip the fixed zipfile:
unzip filename2.zip
and have successfully extracted all the files!
Many thanks to Fattaneh Talebi for the help!
you can extract specific file from zip
$ unzip -j "zipedfile.zip" "file.txt"
file.txt is the file you want to extract from zipedfile.zip
I had the similar kind of problem and it got solved by unar command.
unar file.zip
try extracting directories to retain control and know where you left off.
eg:
tar tv --wildcards -f siteRF.tar './Movies/*'
I tried all the steps mentioned above to unzip the file, but failed miserably.
My last resort was to copy my zip file (11.1GB) into a hard drive and unzip it using 7 zip on Windows 8 OS.
Worked like a charm :D
I also solved it in similar manner like Irene W did. It was a corrupted zip. I first fixed the file with:
zip -FF original_corrupted.zip --out fixed_file.zip -fz
then unzip the fixed zip file:
unzip fixed_file.zip
so I did this
tar cvzf test.zip FP
with the intention of creating a zip of the directory FP
however, it instead lists the directories inside the zip
FP/
FP/php/
FP/php/pdf/
FP/php/docs/
FP/aspnet/
FP/aspnet/pdf/
FP/aspnet/docs/
how do I go about tarring the directory?
Your command is good indeed.
Listing appear when specifying v option (in 'cvzf')
You can check what a gzipped tar file contain by running
$ tar tzvf test.zip
By the way you should avoid to put .zip extension on a "gzipped" tar file. If you really want to make a zip, use 'zip' package instead.
I think it DID create it. The list is just the command being verbose (-v).