分享

Uncompress multiple .zip .gz or .bz2

 农夫子oice 2007-07-06
多重压缩

Uncompress multiple .zip .gz or .bz2 .

.zip

for file in *.zip; do unzip "${file}"; done

.gz

gunzip *.gz

.bz2

bunzip2 *.bz2

tar.gz

for file in *.tar.gz; do tar zxf "${file}"; done

tar.bz2

for file in *.tar.bz2; do tar jxf "${file}"; done

Shell script usage

If you use one of the snippets that uses a for loop in a script with an arbitrary number of archives, you may want to set the shell to use "nullglobs". For instance, normally *.tar.gz will evaluate to *.tar.gz when no files were found that match this wildcard, rather than evaluating to an empty string. As a result ‘tar‘ is executed with this string as a parameter. To avoid this, you can request that the shell uses nullglobs with:

shopt -s nullglob

If no matches were found, the shell will return an empty string, and the for loop is terminated.

TipsAndTricks/UncompressMultipleFiles (2007-06-07 18:23:16由RalphAngenendt编辑)

 
 

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多