𝓩𝓲𝓜

𝓩𝓲𝓜

开心的人生比什么都重要
email
github

Unzip zip, rar, 7z files in Linux.

1. Installation#

Install 7zip#

sudo apt install p7zip-full

Install unrar#

sudo apt install rar unrar

# If the above command fails to install, you can manually install it
sudo wget https://www.rarlab.com/rar/rarlinux-x64-700b2.tar.gz
sudo tar -zxvf rarlinux-x64-700b2.tar.gz
sudo cp rar/rar rar/unrar /usr/local/bin

2. Usage#

Extract 7z files#

# Extract to current directory
7z x compressed.7z

# Extract to same name directory
7z x compressed.7z -o*

# Extract to specified directory
7z x compressed.7z -o/path/to/dest

# Extract encrypted archive
7z x compressed.7z -pPASSWORD

Extract zip files#

7zip can also be used to extract zip files, usage is the same as above.

Extract rar files#

# Extract to current directory
unrar x compressed.rar

# Extract to specified directory
unrar x compressed.rar /path/to/dest

# Extract encrypted archive
unrar x compressed.rar -pPASSWORD

3. Batch extraction#

Use the find command to perform batch extraction

find /path/to/folder -name "*.7z" -exec 7z x {} \;
find /path/to/folder -name "*.zip" -exec 7z x {} \;
find /path/to/folder -name "*.rar" -exec unrar x {} \;

# Extract all archives in current directory to same name folder
find -name "*.7z" -exec 7z x {} -o* \;
find -name "*.zip" -exec 7z x {} -o* \;
find -name "*.rar" -exec sh -c 'mkdir -p "$(basename "{}" .rar)" && unrar x "{}" "$(basename "{}" .rar)"' \;
Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.