我如何在Perl中tar多个文件? [英] How can I tar multiple files in Perl?
问题描述
如何对多个目录进行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屋!