How to create a sub-zip based on the contents of another zip? - linux

I would like to create a zip that contains just a subset based on another zip file. Is there a smarter way to do this than just extracting the specific files and then re-zipping them under a new name?
I'm looking for an efficient way to do this, as the original file will contain thousands and thousands of files and will have a rough size of ~30 GB.

by deleting other stuff e.g.:
zip --delete file.zip junk/*
Second option is by listing zip file with
zipinfo -1 file.zip >list.files
and edit temporally file list to include. Then you
unzip file.zip $(cat list.files)
and create new zip file. Of course the same file can be used for exclusion for zip --delete. Or you can do the same using its on the fly file list in combination with grep for instance.
Check also https://bitbucket.org/agalanin/fuse-zip

Related

Compare files to files inside a Zip archive

I have a zip file which I extract to a folder. I then need to open the files and perform various functions but the files are not modified or saved at all.
I use Dotnetzip to extract the files from the archive before the files are opened and viewed etc.
Is there a way to compare the files, which was extracted, to the files still inside the zip file without extracting those files again? The zip files I have is quite large. Some of them several 100 Mb's so don't want to wait for another extraction process again.
Thanks!

Split large file into small files with particular extension

I want to split a large file into small files of 10000 lines each. I know I can do the same using:
split --lines=10000
However, the above command does not give extensions to the splitted files. I want to give all my split files the extension .txt Is it possible to do the same using split in linux. If yes, then how?
Also is it possible to number the files such that the first file has the name a1.txt. The second file has the name a2.txt, and so on. I know split gives names of the files as aa,ab, etc. but I want to replace this with a1.txt, a2.txt, a3.txt, a4.txt, a5.txt, a6.txt, a7.txt, etc.
Uses the -d parameter, as:
split --lines=10000 -d <file>

Importing list of files to compress/zip

Does anybody know of any way (on Windows) to create an archive (zip, rar,..) and adding files to it by importing a list of files to be added (say from a CSV or text file or simply pasted) that need to be archived. Say I have a simple list of 1,000 files across multiple directories that I want to add to an archive, this would be a much simpler method of doing it than adding each file individually. Also I do not want to arhive the entire directory as it is absolutely massive.
eg:
c:\somedir\file1.php
c:\somedir\somesubdir\file2.php
c:\someotherdir\file3.php
...
And no I do not want to import all files in certain directories, the hundreds of files are scattered across tens of directories which also contain lots of other files that I do not want to archive.
Thanks
rar.exe from WinRAR has the following option:
n#<list> Include files listed in specified list file

Getting files names inside a rar/zip file without unzip

Does anyone know if it is possible to get the name of files inside a rar/zip without having to unrar/unzip the file.. and if yes, is there a way to block it or make difficult..
Thanks
The file names in a zip file are visible even if the data is encrypted. If you want to hide the names, the easy solution is to zip the zip file encrypted.
Later versions of PKZip do have an option to encrypt the file names as well with –cd=encrypt. (cd means central directory.)
The -l flag to unzip(1) does just that:
-l
list archive files (short format). The names, uncompressed file sizes and modification dates and times of the specified files are printed, along with totals for all files specified.
unrar(1) has the l option:
l
List archive content.

How to change a file inside an archive (.ear) file without extracting entire file

I have an .ear file (an archive file like tar / zip) that has a file inside that i want to change.
For example myfile.ear contains 1.txt and i want to change 1.txt to 2.txt and possibly also change some of the content inside 1.txt (like sed does)
I really want to avoid having to extract myfile.ear, change the file and compress it again.
Does anyone know a way to achieve this in linux ?
And if it's not possible, I would also like to know why
Thanks.
EAR files are just JAR files which are just ZIP files. The ZIP format, IIRC, contains metadata and data interleaved, so changing one file (which might be larger/smaller than the file it is replacing) might not fit (or leave a gap), thus in all practical terms the file must be rewritten when doing modifications.

Resources