繁体   English   中英

shell如何对目录中的所有文件应用功能并将结果复制到另一个文件夹中?

[英]shell how to apply a function to all the files in the directory and copy in another folder the results?

zcat 7days/src_file1.gz | head | ./addsubnets.py rndc_subnets.cfg |
    gzip -9c > 7days_subnet/src_file1.gz

我有这个外壳功能。 它将操作应用于7days文件夹中的文件,并将其保存在7days_subnet文件夹中。 如何在7days对所有文件重复此操作?

for file in 7days/*; do
    file=${file#7days/}

    zcat 7days/"$file" | head | ./addsubnets.py rndc_subnets.cfg |
        gzip -9c > 7days_subnet/"$file"
done

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM