| ★ wanayoo — archive 1999 http://oreilly.linux.com/pub/a/linux/lpt/20_08.html | Nouvelle recherche | Portail wanayoo |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
![]() |
|
|
Sponsored by: |
|||
Unix Power Tools
by Jerry Peek
|
Note |
When using |
The proper way to handle the incorrect example above is to use the
- C flag:
% tar cvf /dev/rmt8 project -C /usr local
This will archive
/usr/local/...
as
local/....
For the above options to work when you extract files from an archive, the pathname given in the include or exclude file must exactly match the pathname on the tape.
Here's a sample run.
I'm extracting from a file named appe.tar.
Of course, this example applies to tapes, too:
% tar tf appe.tar
appe
code/appendix/font_styles.c
code/appendix/xmemo.c
code/appendix/xshowbitmap.c
code/appendix/zcard.c
code/appendix/zcard.icon
Next, I create an exclude file, named exclude, that
contains the lines:
code/appendix/zcard.c
code/appendix/zcard.icon
Now, I run the following tar command:
% tar xvfX appe.tar exclude
x appe, 6421 bytes, 13 tape blocks
x code/appendix/font_styles.c, 3457 bytes, 7 tape blocks
x code/appendix/xmemo.c, 10920 bytes, 22 tape blocks
x code/appendix/xshowbitmap.c, 20906 bytes, 41 tape blocks
code/appendix/zcard.c excluded
code/appendix/zcard.icon excluded
If you're archiving the current directory (.) instead of starting at a subdirectory,
remember to start with two pathnames in the Exclude file:
the archive that tar creates and the Exclude
file itself. That keeps tar from trying to archive its
own output!
% cat > Exclude
./somedir.tar
./Exclude
CTRL-d
% find . -type f -print | \
egrep '/,|%$|~$|\.old$|SCCS|/core$|\.o$|\.orig$' >>Exclude
% tar cvfX somedir.tar Exclude .
In that example, we used cat > to create the file
quickly; you could use a text editor instead. Notice that the
pathnames in the Exclude file start with ./; that's what the tar command
expects when you tell it to archive the current directory (.). The long
find/egrep command line uses the
>> operator to add other pathnames to the end of
the Exclude file.
Or, instead of adding the archive and exclude file's pathnames to the
exclude file, you can move those two files somewhere out of the
directory tree that tar will read.
|
|
|
|
|
|
|
Copyright © 2000 O'Reilly and Associates, Inc. All Rights Reserved. All trademarks and registered trademarks appearing on the O'Reilly Network are the property of their respective owners. |
|
|
|
|