Web Hosting Talk







View Full Version : tar /gzip and exclusion of directories


eva2000
09-23-2001, 12:12 PM
wonder if this is possible and what the exact syntax is..

i.e. if i had a directory


/home
/public_html
/directory1
/directory2
/directory3

now if i wanted to tar up all of public_html

i'd type

cd /home
tar cvf public.tar public_html

but what if i want to tar up all except directory1 and directory3 (exclude directory1 and directory3) ?

what should i type ?

thanks

Jm4n
09-23-2001, 02:26 PM
man tar -- that will give you the information you need.

What you're looking for is --exclude. For example:

tar -zcf -C /home public_html --exclude public_html/dir1 --exclude public_html/dir2 ...

The -C makes 'tar' change to directory /home, and the exclude path is relative to /home.
Again, you should familiarize yourself with the 'tar' command by reading the man pages; everything you ever wanted to know about 'tar' is in there, and then some.