カレントディレクトリの全ZIPファイルを展開 / 全ディレクトリをzip圧縮
超やっつけ。
1. カレントディレクトリの全ZIPファイルを展開
find . -maxdepth 1 -mindepth 1 -type f -name "*.zip" -exec unzip {} -d {}.files \;
find . -maxdepth 1 -mindepth 1 -type d -exec zip -r {}.zip {} \;
追記
ちなみに、findにはexecオプションを複数指定可能で、左から順番に処理されるらしい。
たとえば、1でついでにzipファイルの削除を行いたい場合は
find . -maxdepth 1 -mindepth 1 -type f -name "*.zip" -exec unzip {} -d {}.files \; -exec rm {} \;
とすればいい。
また、-execオプションの代わりに-okオプションを指定すると、実行前に確認が行われる。
先ほどのスクリプトで削除の確認を行いたい場合は、
find . -maxdepth 1 -mindepth 1 -type f -name "*.zip" -exec unzip {} -d {}.files \; -ok rm {} \;
となる。速度を気にするならxargs使うべきだが。
追記2
[*.zip]の他に[*.ZIP]や[*.Zip]等も含ませたいときは -iname が使える。これは大文字小文字を区別しない事をのぞいて -name と同じ挙動をするオプションである。
もっと複雑なファイル名の指定をしたい場合は -regex や -iregex 等が良いだろう。詳しいfindのオプションはmanやココなどを参照。