Zip a file in unix


















I suppose technically this is gzip, so that's fine. I guess. Pretty obviously not what the question asked for though. If you don't have zip and unzip packages installed and you have java, you can use jar to unzip: jar -xf file. Not my server, no unzip, zip, 7z, nothing And this worked. This is a great tip. We need jdk in advance to execute this command.

Compressing: 7za a archive. If you want to use the same compression algorithm with your tarballs, use the -J switch with tar : tar cJf archive.

Bob 1 1 silver badge 12 12 bronze badges. I should perhaps append this answer with atool , it's a nice little tool that makes using many different compressors more comfortable. Bind that to a and creating an archive becomes a arc. Starfish Starfish 3 3 silver badges 12 12 bronze badges. I know this is an old thread but this is the best answer. Doesn't talk about 7z or tar, its concise and straight to the point — Kyle. BSD Tar can also do this bsdtar -a -c -f sunday. Zombo Zombo 5, 5 5 gold badges 39 39 silver badges 58 58 bronze badges.

BSD tar has the benefit of supporting quite a few additional compression formats compared to GNU tar and other tar s. The greatest benefit is, perhaps, that it does so while using a tar -like syntax. You can surely use 7z , unrar , unzip , etc from the commandline, but they use a different syntax. Prajwal Dhatwalia 1 1 gold badge 7 7 silver badges 10 10 bronze badges. Does pax support zip archives? Nope and it doesn't support pax archives either! This covers only extraction.

Stephen Kitt k 45 45 gold badges silver badges bronze badges. JackLeo JackLeo 2 2 silver badges 14 14 bronze badges. Let's say I modified the files Foo. Let's say I create a file called modified-files. R Sahu R Sahu 1 1 silver badge 7 7 bronze badges. The Overflow Blog. Podcast Making Agile work for data science.

Stack Gives Back Featured on Meta. New post summary designs on greatest hits now, everywhere else eventually. The program is useful for packaging a set of files for distribution; for archiving files; and for saving disk space by temporarily compressing unused files or directories.

The default behavior with no options is to extract into the current directory and sub-directories below it all files from the specified ZIP archive. Options : 1. After creating a zip file, you can remove a file from the archive using the -d option. Suppose we have following files in my current directory are listed below: hello1. This option can be used to update the specified list of files or add new files to the existing zip file.

Update an existing entry in the zip archive only if it has been modified more recently than the version already in the zip archive. If a directory becomes empty after removal of the files, the directory is also removed. No deletions are done until zip has created the archive without error. This is useful for conserving disk space, but is potentially dangerous removing all input files.

Skip to content. Change Language. An entire directory structure can be packed into a zip archive with a single command. Compression ratios of to are common for text files. When given the name of an existing zip archive, zip will replace identically named entries in the zip archive or add entries for new names. For example, if foo. After this, foo. If the file list is specified as - , [Not on MacOS] zip takes the list of input files from standard input. Under UNIX, this option can be used to powerful effect in conjunction with the find 1 command.

For example, to archive all the C source files in the current directory and its subdirectories: find. For example: zip -r -. For example: tar cf -. This generally produces better compression than the previous example using the -r option, because zip can take advantage of redundancy between files.

The backup can be restored using the command unzip -p backup tar xf - When no zip file name is given and stdout is not a terminal, zip acts as a filter, compressing standard input to standard output. For example, tar cf -. If the name of the zip archive does not contain an extension, the extension.

If the name already contains an extension other than. A self-extracting executable archive is created by prepending the SFX stub to an existing archive. The -A option tells zip to adjust the entry offsets stored in the archive to take into account this "preamble" data. Note: self-extracting archives for the Amiga are a special case. At present, only the Amiga port of Zip is capable of adjusting or updating these without corrupting them.

This option is only useful when updating an existing archive, and the file system containing this old archive does not have enough space to hold both old and new archives at the same time. File operations adding, updating are done first, and the user is then prompted for a one-line comment for each file. Enter the comment followed by return, or just return for no comment.

Note that shell pathname expansion has been inhibited with backslashes, so that zip can see the asterisks, enabling zip to match on the contents of the zip archive instead of the contents of the current directory.

Under systems where the shell does not expand wildcards, such as MSDOS, the backslashes are not needed. Good for exporting files to foreign operating-systems. Resource-forks will be ignored at all. Directory entries are created by default so that their attributes can be saved in the zip archive. The password prompt is repeated to save the user from typing errors. For example: Tag Description zip -f foo This command should be run from the same directory from which the original zip command was run, since paths stored in zip archives are always relative.

Note that the timezone environment variable TZ should be set according to the local timezone in order for the -f , -u and -o options to work correctly. The reasons behind this are somewhat subtle but have to do with the differences between the Unix-format file times always in GMT and most of the other operating systems always local time and the necessity to compare the two.

This option can be used if some portions of the archive are missing. It is not guaranteed to work, so you MUST make a backup of the original archive first. When doubled as in -FF the compressed sizes given inside the damaged archive are not trusted and zip scans for special signatures to identify the limits between the archive members. The single -F is more reliable if the archive is not too much damaged, for example if it has only been truncated, so try this option first.

Neither option will recover archives that have been incorrectly transferred in ascii mode instead of binary. After the repair, the -t option of unzip may show that some files have a bad CRC. Such files cannot be recovered; you can remove them from the archive using the -d option of zip.

If this operation fails, zip attempts to restore the archive to its original state. If the restoration fails, the archive might become corrupted.

The backslash avoids the shell filename substitution, so that the name matching is performed by zip at all directory levels. Not escaping wildcards on shells that do wildcard substitution before zip gets the command line may seem to work but files in subdirectories matching the pattern will never be checked and so not matched.

For shells, such as Win32 command prompts, that do not replace file patterns containing wildcards with the respective file names, zip will do the recursion and escaping the wildcards is not needed. Also possible: Tag Description zip -r foo. When used, zip will not consider Image files eg.

By default, zip will store the full path relative to the current path. The complete path including volume will be stored. By default the relative path will be stored. This option should not be used on binary files. This ensures that unzip -a on Unix will get back an exact copy of the original file, to undo the effect of zip -l. See the note on binary detection for -ll below. This option should not be used on binary files and a warning will be issued when a file is converted that later is detected to be binary.

In Zip 2. This allows unzip -a to convert these files. If a directory becomes empty after removal of the files, the directory is also removed.

No deletions are done until zip has created the archive without error.



0コメント

  • 1000 / 1000