批量解压到文件夹路径
Bulk Unziping Into Folders Path
我有基于 Linux 域的服务器:
domain1.com
public_html
archive1.zip
domain2.com
public_html
archive2.zip
domain3.com
public_html
archive3.zip
我正在尝试 运行 通过以下方式解压缩:
unzip */public_html/*.zip
它非常适合一个域(除了它在我启动此命令的文件夹中解压缩这一事实)。
有没有办法批量解压得到如下输出:
domain1.com
public_html
archive1.zip
content_of_archive1
domain2.com
public_html
archive2.zip
content_of_archive2
domain3.com
public_html
archive3.zip
content_of_archive3
感谢您的宝贵时间和帮助!
这需要一个 for 循环:
for archive in */public_html/*.zip; do
unzip "$archive" -d "$( dirname "$archive" )"
done
PS:我打算使用 pushd
移动到目录,但@Mihir 在他们的评论中提供了 -d
的更简单的解决方案。
PPS:您不需要脚本来 运行 这个 - 只需在 bash 提示符下逐字输入,包括换行符。或者你可以把它折叠成 one-liner:
for archive in */public_html/*.zip; do unzip "$archive" -d "$( dirname "$archive" )"; done
或者,bash
命令历史记录会让您返回到您键入的内容,并根据需要修改 and/or 重新运行。
我有基于 Linux 域的服务器:
domain1.com
public_html
archive1.zip
domain2.com
public_html
archive2.zip
domain3.com
public_html
archive3.zip
我正在尝试 运行 通过以下方式解压缩:
unzip */public_html/*.zip
它非常适合一个域(除了它在我启动此命令的文件夹中解压缩这一事实)。
有没有办法批量解压得到如下输出:
domain1.com
public_html
archive1.zip
content_of_archive1
domain2.com
public_html
archive2.zip
content_of_archive2
domain3.com
public_html
archive3.zip
content_of_archive3
感谢您的宝贵时间和帮助!
这需要一个 for 循环:
for archive in */public_html/*.zip; do
unzip "$archive" -d "$( dirname "$archive" )"
done
PS:我打算使用 pushd
移动到目录,但@Mihir 在他们的评论中提供了 -d
的更简单的解决方案。
PPS:您不需要脚本来 运行 这个 - 只需在 bash 提示符下逐字输入,包括换行符。或者你可以把它折叠成 one-liner:
for archive in */public_html/*.zip; do unzip "$archive" -d "$( dirname "$archive" )"; done
或者,bash
命令历史记录会让您返回到您键入的内容,并根据需要修改 and/or 重新运行。