Shell command to tar directory excluding certain files/folders

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

    You can exclude directories with --exclude for tar.

    If you want to archive everything except /usr you can use:

    tar -zcvf /all.tgz / --exclude=/usr
    

    In your case perhaps something like

    tar -zcvf archive.tgz arc_dir --exclude=dir/ignore_this_dir
    

提交回复
热议问题