1 |
tar version |
2 |
|
3 |
#################################################### |
4 |
tar (GNU tar) 1.34 |
5 |
Copyright (C) 2021 Free Software Foundation, Inc. |
6 |
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>. |
7 |
This is free software: you are free to change and redistribute it. |
8 |
There is NO WARRANTY, to the extent permitted by law. |
9 |
|
10 |
Written by John Gilmore and Jay Fenlason. |
11 |
#################################################### |
12 |
|
13 |
I'm passing on this solution to help others avoid my frustration and |
14 |
wasted time. If you've done "RTFM" on tar, you'll find out that "TFM" |
15 |
is broken or out-of-date or whatever, re: "--exclude=PATTERN". I'm |
16 |
fighting the urge to turn this into a rant. Here's my situation... |
17 |
|
18 |
I either log in as root or "su -" and then "cd /home". I want to tar |
19 |
up /home/waltdnes, and transfer it to another machine. While I'm at it, |
20 |
I want to exlude directory /home/waltdnes/.cache/ and all *.xz files in |
21 |
directory /home/waltdnes/pm/ The "--exclude=" never worked. After much |
22 |
hair pulling, I was ready to give up on the exclude, and simply transfer |
23 |
all the unnecessary garbage. |
24 |
|
25 |
Then "I asked Mr. Google". It seems that I wasn't the only person |
26 |
running into problems. After some searching, I finally found a syntax |
27 |
that works... |
28 |
|
29 |
#################################################### |
30 |
#!/bin/bash |
31 |
export GZIP=-9 |
32 |
tar cvzf wd.tgz --exclude ".cache/*" --exclude "pm/*.xz" waltdnes |
33 |
#################################################### |
34 |
|
35 |
Notes... |
36 |
|
37 |
1) This is obviously not in line with the man page. Specifically, |
38 |
"--exclude" is followed by one space, not an equals sign. |
39 |
|
40 |
2) ***THERE MUST BE EXACTLY ONE SPACE BETWEEN EACH WORD*** |
41 |
|
42 |
3) All directories and/or files to exclude must be listed as relative |
43 |
paths to the directory being tarred, i.e. last parameter on the command |
44 |
line. |
45 |
|
46 |
4) I don't know the maximum line-length, which would limit the number of |
47 |
--exclude entries. In those cases, I wonder if "--exclude-from=FILE" |
48 |
works as "--exclude-from FILE". |
49 |
|
50 |
-- |
51 |
Walter Dnes <waltdnes@××××××××.org> |
52 |
I don't run "desktop environments"; I run useful applications |