Find all zips, and unzip in place - Unix

Use -execdir instead of -exec, which runs the command in the directory where the file is found, not the directory you run find from.

find . -name '*.zip' -execdir unzip '{}' ';'

find . -name '*.zip' | xargs -n1 unzip

find . -name '*.zip' -exec sh -c 'unzip -d `dirname {}` {}' ';'

This command looks in current directory and in its subdirectories recursively for files with names matching *.zip pattern. For file found it executes command sh with two parameters:

-c

and

unzip -d `dirname <filename>` <filename>

Where <filename> is name of file that was found. Command sh is Unix shell interpreter. Option -c tells shell that next argument should be interpreted as shell script. So shell interprets the following script:

unzip -d `dirname <filename>` <filename>

Before running unzip shell expands the command, by doing various substitutions. In this particular example it substitutes

`dirname <filename>`

with output of command dirname <filename> which actually outputs directory name where file is placed. So, if file name is ./a/b/c/d.zip, shell will run unzip like this:

unzip -d ./a/b/c ./a/b/c/d.zip

In case you ZIP file names or directory names have spaces, use this:

find . -name '*.zip' -exec sh -c 'unzip -d "`dirname \"{}\"`" "{}"' ';'