RAK's box Flag: fi Suomeksi


Version 1.0

Multi-file-archive is a linux (dash) shell script, that creates or extracts multi-file .tar.gz archive. It is released under GPL ver 3.


How to install
Change log

How to install

Download multi-file-archive.sh version 1.0. This archive has three files:

To use the script from a folder, for example ~/scripts, move the archive multi-file-archive_1.0.tar.gz to the folder, change to that folder, extract the package, and make the script executable:

mv multi-file-archive_1.0.tar.gz ~/scripts/.
cd ~/scripts
tar -zxvf multi-file-archive_1.0.tar.gz
chmod +x multi-file-archive.sh

Now you can test running the script:

./multi-file-archive.sh -H



Multi-file-archive creates .tar.gz archives into multiple files, or extracts file(s) from such archives. The given archive name is completed by multi-file-archive to include the sequence number and the .tar.gz suffix.

Multi-file-archive uses tar(1) command's multi-volume option to handle a multi-file archive. It automates the file naming. Multi-file-archive uses gzip(1) to compress/uncompress the archive files.

It is mandatory to give either --create, --list, or --extract option. Unlike in tar(1) command, the preceeding dash is required when using the short form of these options. It is also mandatory to give the archive file name with a --file option.

Multi-file-archive does not overwrite existing archives. For example, if the given name for a --file option is testarc, then the operation is interrupted, if there are files named as:


multi-file-archive --help
multi-file-archive --manual
multi-file-archive --version
multi-file-archive -c|t|x [options] --file=archive [pathname ...]


Most options have two alternative forms: either a dash with a single option letter, or two dashes with a long option name.

-c or --create
Create a new archive.
-f archive or --file=archive
Archive file name. This option is mandatory.
-h or --help
Print a help text and exit.
-H or --manual
Display the manual page, file multi-file-archive.1.gz, and exit. Note, that the file must be stored in the same directory as the script multi-file-archive.sh.
-L integer or --size=integer or --tape-length=integer
Set the file size in kilobytes. This is used when the data is split into several tar files (before compressing each tar file with gzip). Default is 80 x 1024kB = 80MB.
-t or --list
List the contents of the archive.
-v or --verbose
Print more details of what is being done.
Print version information and exit.
-x or --extract or --get
Extract file(s) from the archive.

Exit status

An option --help, --manual, or --version was given.
Multi-file-archive detected an error.
0, 1, ...
Exit status given by tar(1) command.


Multi-file-archive does not implement all tar(1) functions.

Multi-file-archive can only create archive files 001...999. If the data to be archived is larger, then the operation is interrupted. Possible solutions: use larger archive file --size, or use less data.

Multi-file-archive was written and tested with dash (Debian Almquist shell), which is the Debian default /bin/sh for the time being. If and how multi-file-archive operates in other shells is untested.


All of the following examples assume that multi-file-archive.sh and multi-file-archive.1.gz are stored in ~/scripts/.

~/scripts/multi-file-archive.sh -cf testarc testpath/
Create an archive testarc from data in testpath, where the uncompressed size of each archive file is 80MB, and they are named as
~/scripts/multi-file-archive.sh -L 1024 -cvf testarc testpath/
Create an archive testarc from data in testpath, where the uncompressed size of each archive file is 1MB. The operation is verbose.
~/scripts/multi-file-archive.sh -tf testarc
List contents of the archive testarc.
~/scripts/multi-file-archive.sh -xf testarc
Extract all contents from the archive testarc.
~/scripts/multi-file-archive.sh -xf testarc testpath/testfile.txt
Extract file testpath/testfile.txt from the archive testarc.
~/scripts/multi-file-archive.sh -H
Display the manual.
man -l ~/scripts/multi-file-archive.1.gz
Another way to display the manual.


Copyright (C) 2015 Risto A. Karola
License GPLv3: GNU GPL version 3. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.

Change log

Version 1.0 2015-03-05 Risto Karola
The initial release.