Shell command to tar directory excluding certain files/folders

后端 未结 28 2288
春和景丽
春和景丽 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:12

    Use the find command in conjunction with the tar append (-r) option. This way you can add files to an existing tar in a single step, instead of a two pass solution (create list of files, create tar).

    find /dir/dir -prune ... -o etc etc.... -exec tar rvf ~/tarfile.tar {} \;
    

提交回复
热议问题