【Mac】tar 打包指定目录并排除某些目录或文件
生活随笔
收集整理的這篇文章主要介紹了
【Mac】tar 打包指定目录并排除某些目录或文件
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
如題,bash腳本如下:
#!/bin/bashDIR=$1 # 要打包的目標(biāo)目錄# 排除的目錄列表 if [ "$1" = "retail" ]; thenarray=(logs lib target .idea .mvn) elif [ "$1" = "manager" ]; thenarray=(.idea update data/log data/runtime simplewind public/static/ui/lib public/static/js)#array=(.idea update data/log data/runtime) elseecho "Usage: sh tar.sh <dir>"exit fiexcludes= for item in ${array[@]} doexcludes="$excludes --exclude $DIR/$item" done# 打包時排除指定目錄 tar $excludes -zcf $DIR.tar.gz $DIR使用時: sh tar.sh targetDir
總結(jié)
以上是生活随笔為你收集整理的【Mac】tar 打包指定目录并排除某些目录或文件的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 树状数组 + 位运算 LA 4013 A
- 下一篇: nohup 命令详解