Archiving: Difference between revisions
Jump to navigation
Jump to search
Created page with "Creating archives and compress files. =Windows= ==zip== ;zip archive.zip file :Create or update archive.zip, put file in there. If file is already existing in the archive it..." |
No edit summary |
||
| (6 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
Creating archives and compress files. | Creating archives and compress files. | ||
==zip== | ==zip== | ||
Available on most operating systems | |||
;zip archive.zip file | ;zip archive.zip file | ||
:Create or update archive.zip, put file in there. If file is already existing in the archive it is replaced. | :Create or update archive.zip, put file in there. If file is already existing in the archive it is replaced. | ||
| Line 11: | Line 11: | ||
:Extract file from archive.zip and put it in the current directory | :Extract file from archive.zip and put it in the current directory | ||
;unzip | ;unzip archive.zip path | ||
:Extract path from archive.zip and put it in the current directory | :Extract path from archive.zip and put it in the current directory. Use quotes if path has wildcards. | ||
;unzip -l archive.zip | |||
:List all files in the archive. | |||
;unzip -l archive.zip path | |||
:List path if it is in the archive. | |||
==tar== | ==tar== | ||
Available on Unix-like operating systems | |||
;tar cvf archive.tar path | |||
:Create archive.tar and put all file under path in it. Be verbose, list what is done (-v) | |||
;tar xvf archive.tar path | |||
:Extract path from archive.tar, put it in the current directory. Be verbose, list what is done (-v) | |||
;tar tf archive.tar path | |||
:List what is in archive.tar. | |||
;tar cvzf archive.tgz path | |||
:Create gzipped archive.tgz and put all file under path in it. Be verbose, list what is done (-v). | |||
:Similar for x and t, the z makes tar work on gzipped archives; | |||
;tar uvf archive.tar --no-recursion --files-from - | |||
:Read filenames from standard input e.g. as found by [[find]] and update the archive. | |||
==gzip== | ==gzip== | ||
;gzip <filename> | |||
:Compress file to <filename>.gz | |||
;gzip -c <filename> | |||
:Compress file to standard output. Can be used for log-rotation when the inode of the file should not change as the application keeps it open. | |||
:<code>gzip -c <filename> > <filename>.gz; cp /dev/null <filename></code> | |||
==7zip== | ==7zip== | ||
Available on most operating systems. Provides very good compression | |||
;7za a <archivename>.7z <files> | |||
:Add files to archive, create it when needed. | |||
;7za l <archivename>.7z | |||
:List an archive. | |||
;7za e <archivename>.7z <files> | |||
:Extract <files> from archive without path, all if <files> is omitted. | |||
;7za x <archivename>.7z | |||
:Extract <files> from archive with full path, all if <files> is omitted. | |||
Latest revision as of 13:31, 26 February 2026
Creating archives and compress files.
zip
Available on most operating systems
- zip archive.zip file
- Create or update archive.zip, put file in there. If file is already existing in the archive it is replaced.
- zip -r archive.zip path
- Create or update archive.zip, put path and all below in there. Files existing in the archive are replaced.
- unzip archive.zip file
- Extract file from archive.zip and put it in the current directory
- unzip archive.zip path
- Extract path from archive.zip and put it in the current directory. Use quotes if path has wildcards.
- unzip -l archive.zip
- List all files in the archive.
- unzip -l archive.zip path
- List path if it is in the archive.
tar
Available on Unix-like operating systems
- tar cvf archive.tar path
- Create archive.tar and put all file under path in it. Be verbose, list what is done (-v)
- tar xvf archive.tar path
- Extract path from archive.tar, put it in the current directory. Be verbose, list what is done (-v)
- tar tf archive.tar path
- List what is in archive.tar.
- tar cvzf archive.tgz path
- Create gzipped archive.tgz and put all file under path in it. Be verbose, list what is done (-v).
- Similar for x and t, the z makes tar work on gzipped archives;
- tar uvf archive.tar --no-recursion --files-from -
- Read filenames from standard input e.g. as found by find and update the archive.
gzip
- gzip <filename>
- Compress file to <filename>.gz
- gzip -c <filename>
- Compress file to standard output. Can be used for log-rotation when the inode of the file should not change as the application keeps it open.
gzip -c <filename> > <filename>.gz; cp /dev/null <filename>
7zip
Available on most operating systems. Provides very good compression
- 7za a <archivename>.7z <files>
- Add files to archive, create it when needed.
- 7za l <archivename>.7z
- List an archive.
- 7za e <archivename>.7z <files>
- Extract <files> from archive without path, all if <files> is omitted.
- 7za x <archivename>.7z
- Extract <files> from archive with full path, all if <files> is omitted.