Gentoo Archives: gentoo-user

From: Mark Knecht <markknecht@×××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] How to untar without first knowing the tar contents?
Date: Thu, 25 Feb 2010 20:10:47
Message-Id: 5bdc1c8b1002251142k722d2124x37ae2b4ab4ef7e42@mail.gmail.com
In Reply to: Re: [gentoo-user] How to untar without first knowing the tar contents? by Florian Philipp
1 On Thu, Feb 25, 2010 at 10:18 AM, Florian Philipp
2 <lists@f_philipp.fastmail.net> wrote:
3 > Mark Knecht schrieb:
4 >> Hi,
5 >>    I backed up my wife's home directory using tar in preparation to
6 >> moving her to a new machine but I don't remember the exact command I
7 >> used to do the tar command. When I tried to untar on the new machine
8 >> it failed to do anything. (except use 30 minutes of CPU time...)
9 >>
10 >> MacMini home # tar -xjf /mnt/cdrom/evelyn.20100214.tar.bz2 /home/evelyn/
11 >> tar: /home/evelyn: Not found in archive
12 >> tar: Error exit delayed from previous errors
13 >> MacMini home #
14 >>
15 >> I'm currently running
16 >>
17 >> tar -tz /mnt/cdrom/evelyn.20100214.tar.bz2
18 >>
19 >> and it's been going 15 minutes without writing anything to the screen.
20 >> I assume that I need to list the contents of the tar file to figure
21 >> out how to untar but I'm really not sure.
22 >>
23 >>    How do I best proceed?
24 >>
25 >> Thanks,
26 >> Mark
27 >>
28 >
29 > Err, your tar commands are a bit wrong.
30 >
31 > tar -xjf /mnt/cdrom/evelyn.20100214.tar.bz2 /home/evelyn/
32 > tells tar to extract the parts of it which are under home/evelyn to the
33 > working directory.
34 > This might be what you wanted in the first place but I guess you rather want
35 > tar -xjf /mnt/cdrom/evelyn.20100214.tar.bz2 -C /home/evelyn/
36 > which means extracting the complete content of the tar file to /home/evelyn.
37 >
38 > Your second command ... well, where to start:
39 > 1. Since you didn't use the -f switch (as you did correctly in the first
40 > command), tar expects input from stdin, not as a file specified on
41 > commandline. That's why it hasn't done anything in the last 15 minutes.
42 >
43 > 2. With -z you specify that the file is compressed with gzip but the
44 > file ending shows its compressed with bzip2. That's the -j switch
45 > (again, correct in your first command).
46 >
47 > By the way: You should enable the -p switch when extracting the files in
48 > order to restore permissions and so forth.
49 >
50 > Hope this helps!
51 > Florian Philipp
52 >
53 >
54 Wow! I'm really bad! I didn't get that about stdin at all. Never
55 dawned on me... Stupid me...
56
57 Thanks Florian!
58
59 OK, using Neil's suggestion
60
61 tar tfv archivername
62
63 results in the first few lines:
64
65 MacMini ~ # tar tvf /mnt/cdrom/evelyn.20100214.tar.bz2
66 drwx------ evelyn/users 0 2010-02-13 14:50 home/evelyn/
67 drwx------ evelyn/users 0 2008-04-11 17:33 home/evelyn/.AbiSuite/
68 -rw-r--r-- evelyn/users 2614 2008-07-24 01:18
69 home/evelyn/.AbiSuite/AbiWord.Profile
70 drwxr-xr-x evelyn/users 0 2010-02-12 19:21 home/evelyn/.xine/
71 drwxr-xr-x evelyn/users 0 2007-09-19 13:36 home/evelyn/.xine/cddbcache/
72 -rw-r--r-- evelyn/users 761 2007-09-19 13:36 home/evelyn/.xine/cddbcache/5e0
73
74 so I tried
75
76 tar xfv /mnt/cdrom/evelyn.20100214.tar.bz2 -C /
77
78 and because /home/evelyn already exists the files seemed to end up in
79 the right place.
80
81
82 Thanks,
83 Mark