Shell command to tar directory excluding certain files/folders

后端 未结 28 2263
春和景丽
春和景丽 2020-11-27 08:31

Is there a simple shell command/script that supports excluding certain files/folders from being archived?

I have a directory that need to be archived with a sub dire

28条回答
  •  野性不改
    2020-11-27 09:34

    You can use standard "ant notation" to exclude directories relative.
    This works for me and excludes any .git or node_module directories:

    tar -cvf myFile.tar --exclude=**/.git/* --exclude=**/node_modules/*  -T /data/txt/myInputFile.txt 2> /data/txt/myTarLogFile.txt
    

    myInputFile.txt contains:

    /dev2/java
    /dev2/javascript

提交回复
热议问题