Hi,
How about using the regular tar command under unix?
Thanks,
Main Topics
Browse All TopicsHi,
I am wondering how can I exclude a directory from a tar file?
Any help would be appreciated.
Thanks
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
sunnycoder point you to the right directtion.
tar comand is OS depandent. (the native tar command come with OS, some of them does
not support exclude, or use different option flag to do the job)
You don't have the GNU tar install, you can always download it from the web, it support
compression as well. (normally install it in /usr/local/tar, assume that you has set PATH to
use it, otherwise you need to use /usr/local/bin/tar instead of tar).
Here's some examples for how to use it:
#-------------------------
GUN tar (tar with comprssion and excluding options):
tar -czf tarball.tar.gz --exclude=pattern fileslist
eg:
tar -czf website.tar.gz --exclude=*.zip public_html
--exclude-from=file-of-pat
eg:
tar -cvf mytest.tar --exclude-from=testfile bin
tar -czf trial.tar ./* --no-anchored --exclude=./build/lib/*.a --exclude=*/OBJS/* --exclude=*/lib/solaris/*
#testfile has all the excluding patterns
To untar:
tar -zxf website.tar.gz
man tar
to learn more
Some tar's can do this, and some can't.
gnutar's been covered.
Solaris can do this by listing an <exclude-file> containing the names of the files to exclude after the name of the file to create when using -f
HP-UX and AIX can't do this.
Don't know about others.
But all is not lost as you can always use 'pax'. pax is a POSIX-mandated command designed to solve the tar/cpio quagmire and handles this situation quite easily.
find <whatever> | grep -v <whatever> | pax -w -d -x ustar > archive
pax -r -x ustar < archive
See the man page for more info
First, I'd like to suggest using standard tar -- there's no need to get incompatible with
the rest of us UNIXes. Exact information how to exclude files and/or directories from it
can be found at http://www.experts-exchang
Cheers
Business Accounts
Answer for Membership
by: sunnycoderPosted on 2003-09-29 at 21:48:31ID: 9456715
Hi hh125,
e.com/Oper ating_Syst ems/ Q_2075 1425.html
use --exclude flag if you are using gnutar
http://www.experts-exchang
Cheers!
Sunny