Ops-tar命令实用总结

温故而知新。
  • 打包和过滤
tar Jcvf a.tar.xz /data/a /data/b --exclude=/data/a/lia_recording.sql  --exclude=/data/a/test --exclude=/data/a/uploads/* --exclude="/data/a/\.git*"
  • 常见示例
tar -cvf test.tgz test/
tar -cvf test.tgz test/ --exclude *.jpg
tar -cvf test.tgz test/ --exclude *.txt --exclude *.jpg
tar -cvf test.tgz test/ --exclude a.txt
tar -cvf test.tgz test/ --exclude dir1
tar -cvf test.tgz test/ --exclude dir1 --exclude a.log --exclude *.jpg

tar -zcvf test.tar.gz --exclude=test/1/*.log test
tar -zcvf test.tar.gz --exclude=/test\/1\/.*log/ test
tar -zcvf test.tar.gz --exclude=test/1/6 --exclude=test/2 test
tar -zcvf test.tar.gz --exclude=1/6 --exclude=2 test

其中:
        --exclude=/data/li/test 和 --exclude=/data/li/test/在过滤的时候有所不同。如果需要排除掉某个目录的时候,需要使用"--exclude=/data/li/test"。目录后不能加"/";或者使用--exclude=/data/li/test/*
上一篇:harbor安装


下一篇:SQL查询出日期最新的数据MySQL