When using GNU tar (commonly found in Linux distributions) getting tar to exclude a subdirectory can have some tricky pitfalls. Perform the tar command like this:
Note the following:
tar -zcvf mytarball.tar.gz --exclude "/home/user/directoryToTar/subdirAToExclude" --exclude "/home/user/directoryToTar/subdirBToExclude" /home/user/directoryToTar
Note the following:
- The
--exclude
must become before the file list of things to tar - The directory to exclude must be surrounded by double quotes
- The directory to exclude must be a full system path (i.e. not a relative path, such as ./subDirAToExclude)
- The files to include must also be a full system path (i.e. not a relative path, such as ./directoryToTar)
No comments:
Post a Comment