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.

You can run it on a single line with this syntax instead:

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.

If you wanted to use 7zip to extract a list of files:

Or if you wanted to unzip a list of files:

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:

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.