Shell command to tar directory excluding certain files/folders

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

    gnu tar v 1.26 the --exclude needs to come after archive file and backup directory arguments, should have no leading or trailing slashes, and prefers no quotes (single or double). So relative to the PARENT directory to be backed up, it's:

    tar cvfz /path_to/mytar.tgz ./dir_to_backup --exclude=some_path/to_exclude

提交回复
热议问题