Unzip or Unrar Many Files at Once in Linux
- How to setup and Open rar file or Extract rar files under Linux or UNIX?
- Linux/Unix: Simple Backup Command File – Very useful
- Bash Script: How Do I Copy The Missing Files, Directories Alone From a Directory to Another Directory in Linux?
- Unix/Linux: Bulk rename files to all upper or lower case
- Linux / Unix / Bash Help: A check to see if a wildcard expression of files/folders exists or not
If you’ve got a directory with dozens of zipped or rar’d files, you can run a single command to unzip them all in one step, thanks to the power of the bash shell.
For this task, we’ll use bash’s for loop command structure. Replace with a variable name, and
with either a command that outputs a list or an explicit list.
for in
do
command $;
done
You can run it on a single line with this syntax instead:
for in
;do command $;done
So if you want to unrar a list of files, you could use this command. You don’t necessarily need the quotes, but it helps when the filenames have spaces or something like that in them.
for f in *.rar;do unrar e “$f”;done
If you wanted to use 7zip to extract a list of files:
for f in *.001;do 7z e “$f”;done
Or if you wanted to unzip a list of files:
for f in *.zip;do unzip “$f”;done
You could even chain commands together if you wanted to. For instance, if all your zip files contained .txt files and you wanted to unzip them and then move the unzipped files to another directory:
for f in *.zip;do unzip “$f”;done; for f in *.txt;do mv “$f” /myfolder/;done
The bash shell is just so incredibly powerful… this doesn’t even tap the power, but it should give you a good idea of what is possible.
The other way is
for zipfile in *.zip
do
for file in $(unzip -qql $zipfile ‘ awk ‘{print $NF}‘)
do
unzip -d ${file%%.zip} $zipfile $file
done
done

Thank you
This line:
$ for f in *.rar;do unrar e “$f”;done
helped me