Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
多くの tarball を含むフォルダーの階層があります。各ディレクトリに再帰的に移動し、対応するディレクトリに tarball を抽出するスクリプトを作成する必要があります。
私は試した
find ./ -name "*.tar.gz" -exec /bin/tar -zxvf {} \;
コードは、対応するディレクトリではなく、pwd に抽出されたすべての tarball で実行されました。
可能であれば、これについて私を助けてください。ありがとう :)
次のように find を使用できます。
find . -name "*.tar.gz" -exec bash -c 'd=$(dirname "{}") && b=$(basename "{}") && cd "$d" && tar zxvf "$b"' \;
EDIT上記のfindコマンドの短縮版は次のようになります。
find . -name "*.tar.gz" -execdir tar zxvf "{}" \;