Linux exclude certain files formats eg : *.gz *.zip from a tar archive

If you want to exclude certain filetypes from the directory when creating a tar archive use the –exclude parameter for tar

tar -zcvf filename.tar.gz abc_direc/ –exclude=’*.zip’ –exclude=’*.gz’ –exclude=’*.log’ –exclude=’*.pdf’

tar -zcvf wha_clean.tar.gz public_html/ –exclude=’*.zip’ –exclude=’*.gz’ –exclude=’*.log’ –exclude=’*.pdf’ –exclude=’*.jpg’ –exclude=’*.JPG’ –exclude=’error_log’ –exclude=’*.tar’

Category: Linux

Tags:

Leave a Reply

Article by: Shadab Mohammad