我有一些像下面这样的zip文件。
./etk/test/etf_time_series_am_update.zip
./etk/test/etf_time_series_am_delete.zip
./etk/dir1/etf_time_series_am_update.zip
./etk/dir1/etf_time_series_am_delete.zip
./etk/dir1/dir2/etf_time_series_am_update.zip
./etk/dir1/dir2/etf_time_series_am_delete.zip
./etk/dir1/dir2/dir3/etf_time_series_am_update.zip
./etk/dir1/dir2/dir3/etf_time_series_am_delete.zip
我希望这些文件解压缩并存储到另一个文件夹中。喜欢
./newf/test/etf_time_series_am_update.txt
./newf/test/etf_time_series_am_delete.txt
./newf/dir1/etf_time_series_am_update.txt
./newf/dir1/etf_time_series_am_delete.txt
./newf/dir1/dir2/etf_time_series_am_update.txt
./newf/dir1/dir2/etf_time_series_am_delete.txt
./newf/dir1/dir2/dir3/etf_time_series_am_update.txt
./newf/dir1/dir2/dir3/etf_time_series_am_delete.txt
我尝试使用find命令并能够解压缩,但无法复制到目标文件夹中。
我试图通过以下命令解压缩。但不知道复制到目标文件夹。
find -name '*.zip' -exec sh -c 'unzip -d "${1%.*}" "$1"' _ {} \;
答案 0 :(得分:0)
这可能适合你。
find . -name "*.zip" | while read filename; do unzip -o -d "`dirname "$filename" | sed -r 's/etk/newf/g'`" "$filename"; done;
您可以通过参考以下链接获得更好的解决方案。