Create tar file and exclude files or directories / 28 Sep 2015 / Author: Haim Ari

    Estimated read time: 1 min

    Many times i was asked this question:

    ” how can i exclude files when creating tar archive ? ”

    So here is a simple way to create a tar.gz file while excluding files or directories.

    tar -zcv -f target.tar.gz --exclude-from='exclude.txt' source/
    
    in your exclude.txt file you can place the paths to exclude:
    logs/*
    errors
    data/*.bin