Quicky: Unzip multiple files with spaces in their filenames using command line.

You might have run into a similar situation; You need to unzip several ZIP files, but running unzip *.zip command results in errors shown about files not being found. Joy.

Fortunately there's way to avoid this. Unfortunately, it's not something you can easily memorize. Or, I certainly cannot. Credit is to Joakim Nohlgård, who posted this in an answer to a question about this question on Superuser.com.

find . -name "*.zip" -exec sh -c 'unzip -n "{}" | head -n 7' \; 

Note; I added -n to the unzip command, which means it will never overwrite files that already exist. If you'd like to extract all files to a specific folder, you can add -d to the unzip command and provide the path to which it should extract things to, for example:

find . -name "*.zip" -exec sh -c 'unzip -n "{}" -d /path/to/extract/to | head -n 7' \; 

You can modify the command to your liking of course. If, for example, your files are 7zip or RAR files, you could replace the unzip command with 7za.


Note: be sure to have unzip installed. If you are running a Debian-based Linux, you can easily install it by running sudo apt-get install unzip. For 7zip  or RAR files you would have to install p7zip; sudo apt-get install p7zip.