I have a directory called test1
which contains multiple directories. In each directory test1/*/
, there is a *.gz
file that I want to unzip. I tried writing this code but it doesn't work, any help would be appreciated.
for folder in test1/*/; do find . -name "*.gz" | while read filename; do gunzip -d $filename;done ;done
gunzip test1/*/*.gz
gunzip
会将文件gunzip
压缩到其所在的目录中。
You can just do that using find
:
cd test1
find . -name "*.gz" -execdir tar xzf '{}' \;
Remember that unzip
command only works with .zip
files.
PS: If .gz
files have not been created using tar czf
then use gunzip
instead:
find . -name "*.gz" -execdir gunzip '{}' \;
我编辑了命令,现在可以使用:
find ${path} -name "*.gz" | while read filename; do gunzip -d $filename; done
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.