minitar.lua is a minimal tar implementation in Lua, based on LuaX.
minitar.lua is a lightweight and portable utility that allows you to create, extract, and test tar archives.
It supports multiple compression formats (gzip, lzip, xz) and offers path manipulation features during archiving or extraction.
- LuaX and Bang must be installed on your system
- To use compression features, the corresponding tools must be available:
gzipfor gzip compressionxzfor xz compression
lzip is provided by LuaX.
No external dependency is required for the lzip compression.
Download the sources, compile and install minitar:
$ git clone https://codeberg.org/cdsoft/minitar.lua
$ cd minitar.lua
$ bang && ninja installminitar [-h] [-v] [-c] [-x] [-t] [-f archive] [--strip path]
[--add path] [-C path] [<file>] ... [--gzip [level]]
[--lzip [level]] [--xz [level]]
| Argument | Description |
|---|---|
<file> |
List of files to archive, extract or test |
| Option | Description |
|---|---|
-h, --help |
Display help and exit |
-v |
Verbose mode (displays detailed information) |
-c |
Create archive |
-x |
Extract archive |
-t |
Test archive (list its contents) |
-f archive |
Specify archive filename |
| Option | Description |
|---|---|
--strip path |
Remove path components during archiving or extraction |
--add path |
Add path components during archiving or extraction |
-C path |
Change directory before archiving or extracting |
| Option | Description |
|---|---|
--gzip [level] |
Compress with gzip (optional compression level) |
--lzip [level] |
Compress with lzip (optional compression level) |
--xz [level] |
Compress with xz (optional compression level) |
The compression format can be deduced from the output filename.
These options are necessary to change the default compression level (6)
or to compress a stream to the standard output (stdout).
Create a simple tar archive:
minitar -c -f archive.tar file1 file2 folder1Create a tar archive compressed with gzip:
minitar -c -f archive.tar.gz file1 file2 folder1 --gzipCreate a tar archive compressed with xz (compression level 9):
minitar -c -f archive.tar.xz file1 file2 folder1 --xz 9Create an archive after changing directory:
minitar -c -f archive.tar -C /path/to/folder file1 file2Extract a tar archive:
minitar -x -f archive.tarExtract a compressed tar archive (format is automatically detected):
minitar -x -f archive.tar.gzExtract an archive to a specific directory:
minitar -x -f archive.tar -C /path/to/destinationExtract an archive removing the first two directory levels:
minitar -x -f archive.tar --strip 2Display the contents of a tar archive:
minitar -t -f archive.tarDisplay the contents of a compressed tar archive:
minitar -t -f archive.tar.xzThe --strip option allows you to remove path components during archiving or extraction.
Example: If a file in the archive has the path dir1/dir2/dir3/file.txt, then:
--strip 1will result indir2/dir3/file.txt--strip 2will result indir3/file.txt--strip 3will result infile.txt
The --add option allows you to add a prefix to paths during archiving or extraction.
Example: If a file has the path file.txt, then:
--add prefixwill result inprefix/file.txt
minitar.lua supports several compression formats:
- gzip: Standard compression format, good balance between compression ratio and speed
- lzip: Compression format offering better compression than gzip
- xz: Modern compression format offering excellent compression ratio
The compression format is automatically detected during extraction based on the file extension:
.tar.gzor.tgzfor gzip.tar.lzor.tlzfor lzip.tar.xzor.txzfor xz
minitar.lua is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
minitar.lua is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with minitar.lua. If not, see <https://www.gnu.org/licenses/>.
For further information about minitar.lua you can visit
https://codeberg.org/cdsoft/minitar.lua