【发布时间】:2014-04-20 16:43:15
【问题描述】:
我正在尝试动态查找并压缩特定类型的文件,但 TAR 压缩的文件比我找到的要多。 例如:
在这里我发现没有。 7
/mnt/1 % find . -name *.pdf
./. /01.pdf
./slide/01.pdf
./slide/03.pdf
./slide/02.pdf
./.Trash-0/files/01.pdf
./.Trash-0/files/01.2.pdf
./.Trash-0/files/01 - Introduzione ISTI + note.pdf
但是当我动态压缩时,存档还包含其他文件
/mnt/1 % find . -name *.pdf | xargs tar czvf /root/Desktop/evidence/pdf.tar
deft8vm /mnt/1 % tar -tvf /root/Desktop/evidence/pdf.tar
drwxr-xr-x root/root 0 2014-04-14 13:51 ././
drwxr-xr-x root/root 0 2014-04-15 08:27 ././. /
-rw-r--r-- root/root 9070641 2014-04-14 13:40 ././. /01.pdf
drwx------ root/root 0 2014-04-15 08:31 ././. /4Dell/
drwx------ root/root 0 2014-04-15 08:31 ././. /4Dell/4Dell.afd/
-rw-r--r-- root/root 4992592 2014-04-15 08:31 ././. /4Dell/4Dell.afd/file_000.aff.csv
-rw-r--r-- root/root 1051669804 2014-04-15 08:31 ././. /4Dell/4Dell.afd/file_000.aff
-rw-r--r-- root/root 1524 2014-04-15 08:31 ././. /4Dell/4Dell.afd.txt
drwx------ root/root 0 2014-04-14 11:14 ././lost+found/
drwxr-xr-x root/root 0 2014-04-14 13:51 ././slide/
hrw-r--r-- root/root 0 2014-04-14 13:40 ././slide/01.pdf link to ././. /01.pdf
/mnt/1 % tar -tf /root/Desktop/evidence/pdf.tar | wc -l
29
【问题讨论】:
-
指定你要
findfiles:find . -type f -name "*.pdf" | xargs tar czvf /root/Desktop/evidence/pdf.tar -
如果
devnull's上面的例子不清楚。你想要find而不是shell 来处理*.pdf,所以你需要引用它(单引号和双引号都可以防止通配符)