General TC > General TC Talk
Archive List
CentralWare:
Good morning everyone!
I need a little brain-storming to create a function whose job is to determine how to extract an archive file based on the filename.
However, of course, there's a million archive formats out there, so we need to build a laundry list of file extensions along with the command to extract with.
For example:
--- Code: ---case $1 in
*.tar) CMD="tar -xf" ;;
*.tar.gz) CMD="tar -zxf" ;;
*.tar.bz) CMD="tar -jxf" ;;
*.tar.bz2) CMD="tar -jxf" ;;
*.7z) CMD="7z x -so" ;;
*.rar) CMD="unrar x -r" ;;
*.zip) CMD="unzip -a" ;;
esac
--- End code ---
The goal here is to have a working list of commands of supported software, create extensions if necessary for software we don't already have in the repository and have this function detect whether or not said extensions are currently installed. Please list all of the file extensions you can think of along with their associated command to EXTRACT into the CURRENT directory. The above examples were "off the top of my head" so they may not be completely accurate.
The "ultimate" goal is to have the fewest number of extensions needing to be installed in order to support the largest number of archive formats.
This function will also be supporting ISO, RPM, DEB, CPIO and other containers, we probably won't need to support extensions like CAB for obvious reasons, but there's archives out there such as ACE, ALZ, LZH, etc. which aren't overly common today, but worthwhile to implement if they don't require closed source software.
Any file extensions you can think of that you know how to extract... please feel free to contribute!
LOL - if five people have already listed *.xz) CMD="tar -xf" ;; please refrain from adding a sixth! :)
patrikg:
My first comment on this, that you can use the pipe char to reducing repetition in your case statement which works as an "OR" like this:
--- Code: --- *.tar.bz|*.tar.bz2) CMD="tar -jxf" ;;
--- End code ---
patrikg:
I use wimextract to extract some fonts from the iso.
Using a computer that have a M$ license ;)
I installed wimlib in my Arch linux system to get the wimextract program.
So the format wim and cab can be usefull, even if "we" don't want to support the M$ Corp.
--- Code: ---wimextract install.wim 1 /Windows/{Fonts/"*".{ttf,ttc},System32/Licenses/neutral/"*"/"*"/license.rtf} --dest-dir /home/patrik/fonts
--- End code ---
CentralWare:
--- Quote from: patrikg on April 17, 2025, 03:50:32 AM ---My first comment on this, that you can use the pipe char to reducing repetition in your case statement which works as an "OR" like this:
--- Code: --- *.tar.bz|*.tar.bz2) CMD="tar -jxf" ;;
--- End code ---
--- End quote ---
Yes, but for sake of being able to quickly "see" what packages we have on the list vs. what needs to be completed, I currently have two lists going; one for *.tar.gz and other fully listed archives, and a separate list for hybrid/combined extensions such as .tgz - they're the same commands, I'm just trying to cover all bases at the start and we'll combine them once we're ready to push the changes upstream. Or not... We'll see where things land in the end! :)
When combining similar archives, LZH and LHA would go together, but the initial list will be sorted alphabetically to ensure we get all of the necessary packages in here so "OR"ing the list is a little premature just yet.
As for M$, I'm doubtful they'll be putting out too many 'nix based source code packages (which is what this archive project is focused on - extracting people's source code and support packages) so if I (ahem) accidentally leave out a couple which weren't intended for our side of the fence, I'm pretty certain they won't be missed. :)
nick65go:
IMHO, I think 7-zip (ver 24.09) linux version, covers "everything". https://www.7-zip.org/download.html
Please read its help for confirmation that any format can be manipulated from command line.
Supported formats
Format Creation Filename Extensions
7z X 7z
BZIP2 X bz2 bzip2 tbz2 tbz
GZIP X gz gzip tgz
TAR X tar
WIM X wim swm esd
XZ X xz txz
ZIP X zip zipx jar xpi odt ods docx xlsx epub
APFS apfs
APM apm
AR ar a deb lib
ARJ arj
Base64 b64
CAB cab
CHM chm chw chi chq
COMPOUND msi msp doc xls ppt
CPIO cpio
CramFS cramfs
DMG dmg
Ext ext ext2 ext3 ext4 img
FAT fat img
HFS hfs hfsx
HXS hxs hxi hxr hxq hxw lit
iHEX ihex
ISO iso img
LZH lzh lha
LZMA lzma
MBR mbr
MsLZ mslz
Mub mub
NSIS nsis
NTFS ntfs img
MBR mbr
RAR rar r00
RPM rpm
PPMD ppmd
QCOW2 qcow qcow2 qcow2c
SPLIT 001 002 ...
SquashFS squashfs
UDF udf iso img
UEFIc scap
UEFIs uefif
VDI vdi
VHD vhd
VHDX vhdx
VMDK vmdk
XAR xar pkg
Z z taz
ZSTD zst tzst
==FYI:== has minimum dependencies and its size =1.9MB on x86 arch, lovely :)
https://pkgs.alpinelinux.org/package/edge/main/x86/7zip
Navigation
[0] Message Index
[#] Next page
Go to full version