Shell command to tar directory excluding certain files/folders

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

    You can use cpio(1) to create tar files. cpio takes the files to archive on stdin, so if you've already figured out the find command you want to use to select the files the archive, pipe it into cpio to create the tar file:

    find ... | cpio -o -H ustar | gzip -c > archive.tar.gz
    

提交回复
热议问题