How to exclude files/directory when tar - up a files
Linuxmisc » Aix
. How can I do it? In Solaris I can append in a ".Exclude" file, but I cant'
find this option in AIX.
Please advise, Thanks
Andrew
"News Group" <andrew.h...@integration.sungard.com> writes:
You can use the -L option.
Create a file of filenames that you want included in the tar
archive, one filename per line. Then list the name of this
file after the -L option. Tar will only archive exactly what
is listed. Directories are not recursed.
Building the file of filenames isn't too difficult. You can
use "find" to build a complete list and then edit the list
by hand.
find dir -print > list
vi list
tar -c -f tar.out -L list
If you need to automate this, you have several options.
You can pipe the list through "grep -v" or "egrep -v"
to take out lines you don't want.
find dir -print | grep -v skipdir > list
find dir -print | egrep -v 'skipdir|nogood' > list
You can get clever with find and have it omit files
you don't want.
find dir ! -name '*.old' -print > list
find dir \( \( -name skipdir -o -name nogood \) -prune \) \
-o -print > list
For example, suppose you want to archive directory "dir" but
want to skip any file whose name ends with .old. You could
do it like this:
find dir ! -name '*.old' > list
tar -c -f tar.out -L list