我如何在Perl中tar多个文件? [英] How can I tar multiple files in Perl?

查看:173
本文介绍了我如何在Perl中tar多个文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何对多个目录进行tar操作,并附加某些模式的文件,如.txt,并排除某些目录,并将某些模式(如.exe)排除在一个tar文件中。主要的一点是目录的数量是未知的(动态),所以我需要循环我猜?

How can I tar multiple directories and also append files with some pattern like '.txt' and exclude some directories and exclude some patterns like '.exe' all into a single tar file. The main point is the number of directories are unknown(dynamic), so I need to loop through I guess?

推荐答案

假设你已经找出了你想要的文件你使用File :: Find然后像

Assuming you have worked out what files you want using File::Find then something like

    my @dir = qw/a b/ ;
    system "tar -cvf mytar @dir" ;

可能有效。但您可能会发现命令行太长。

might work. But you might find that the command line is too long.

在这种情况下,可以将文件列表写入文件并使用选项

In which case maybe write the list of files to a file and use the option

   --files-from=NAME

(请不要告诉我你不能写文件)

(and please don't tell me you are not allowed to write to files)

这篇关于我如何在Perl中tar多个文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆