カレントディレクトリ以下の複数のディレクトリに存在する全ての圧縮ファイルを、その圧縮ファイルがある場所に再帰的に解凍する。( Linux / 一括解凍)
Linux 端末において "find -exec [command] {} +" コマンドと、" perl -e '...' " ワンライン・スクリプトを併用する。
もしくは、"find -exec [command] ;" コマンドと、" perl -e '...' " ワンライン・スクリプトを併用する。
例 1)
$ find . -type f -name "*.tar.gz" -exec perl -e 'foreach(@ARGV){/(.*)\/(.*)/;system("tar -xvzf \"$_\" -C \"$1\"");}' {} +
例 2)
$ find . -type f -name "*.tar.gz" -exec perl -e '"{}"=~/(.*)\/(.*)/;system("tar -xvzf \"{}\" -C \"$1\"");' \;
なお、上記の "find -exec [command] {} +" 形式のコマンドにおいては、perlコマンドの引数として、find のマッチ結果の文字列(ファイルパス)のリストが渡される。
もしくは、"find -exec [command] ;" 形式のコマンドにおいては、"[command]" 内の "{}" 文字列を 介して、find のマッチ結果の文字列(ファイルパス)が渡される。
(※ キーワード: Linux , 一括解凍 , まとめて解凍)
(for English)
How to extract recursively all the files from every tar archives that exist in subdirectories under the current directory, to the directory where the tar archive exists in. ( Linux / recursively decompress / recursively unzip)
You can use "find -exec [command] {} +" command and " perl -e '...' " formed one-line script together in a linux terminal.
Or, you can use "find -exec [command] ;" and " perl -e '...' " formal command together.
ex 1)
$ find . -type f -name "*.tar.gz" -exec perl -e 'foreach(@ARGV){/(.*)\/(.*)/;system("tar -xvzf \"$_\" -C \"$1\"");}' {} +
ex 2)
$ find . -type f -name "*.tar.gz" -exec perl -e '"{}"=~/(.*)\/(.*)/;system("tar -xvzf \"{}\" -C \"$1\"");' \;
By the way, the matched string (file path) list of "find" is passed over by the default arguments of perl script in a "find -exec [command] {} +" formed command above.
Or, the matched string (file path) of "find" is passed over by the "{}" strings in a "-exec [command] ;" formed command.
(※ keyword: Linux , bunch decompression , bunch unzipping)
ログインしてコメントを確認・投稿する