foxhelp
asked on
Exclude file in tar on SCO Unix
I am using tar to back up a directory in SCO Openserver 5. I want to exclude a directory in that directory. I don't want to back it up. How do I accomplish this using tar.
example:
tar cvf /backup/tarfile /usr/test/ac
this backs up everthing in /usr/test/ac
I want to back up everything but a directory called mar in the "ac" directory.
example:
tar cvf /backup/tarfile /usr/test/ac
this backs up everthing in /usr/test/ac
I want to back up everything but a directory called mar in the "ac" directory.
ASKER
tried that, it still backups up the "mar" directory. Does list= put "mar" in a file or something that I can look at? when I do the tar after the list, it still shows me mar as a directory that is being backed up.
It will backup the directory - but it will be empty - no files under /usr/test/ac/mar will be included.
list=`find /usr/test/ac | grep -v /mar/`
creates a variable that contains the files you want - "grep -v" will exclude "/mar/*" from the list.
try:
list=`find /usr/test/ac | grep -v /mar/`
echo $list
that should show you what it will backup.
If you want to exclude the directory as well you can use this (with a caveat):
list=`find /usr/test/ac | grep -v /mar`
This will exclude both the /usr/test/ac/mar directory and contents, but also any file starting with "mar" in the /usr/test/ac directory.
list=`find /usr/test/ac | grep -v /mar/`
creates a variable that contains the files you want - "grep -v" will exclude "/mar/*" from the list.
try:
list=`find /usr/test/ac | grep -v /mar/`
echo $list
that should show you what it will backup.
If you want to exclude the directory as well you can use this (with a caveat):
list=`find /usr/test/ac | grep -v /mar`
This will exclude both the /usr/test/ac/mar directory and contents, but also any file starting with "mar" in the /usr/test/ac directory.
You could also get gnu tar for openserver - I think it supports the exclude directives:
ftp://ftp2.sco.com/pub/skunkware/osr5/fileutil/tar/
ftp://ftp2.sco.com/pub/skunkware/osr5/fileutil/tar/
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
tar cvf /backup/tarfile $list