test
|-- out
| `-- readme
|-- out1
| `-- out
| `-- test1out1out
|-- out2
`-- test
`-- out
`-- test.out
目录结构 如上,如果不想打包根目录下test/out下的文件夹
命令如下
tar zcvf --exclude=test/out test/
user@user-Z370-HD3:~/sermux$ tar zcvf test.tar.gz --exclude=test/out test
test/
test/out2/
test/out1/
test/out1/out/
test/out1/out/test1out1out
test/test/
我们发现会将/test/test/out/和/test/test/out/test.out这两个也排除了,因为上面两个也包含test/out字段
注意事项:如果排除文件夹,最好不要在文件内部有重名的。
find media/ -name "*.jpg" -o -name "*.png" -print > image.txt
tar czf img.tar -T image.txt
计算文件夹下图片占用多少兆空间
find . -type f -regex '.*\.\(jpg\|png\)$' -printf "%s\n" | awk '{t+=$1}END{print t/1024/1024}'