1. Correct. If you specify the path for the files to archive, tar will create the exact same directory structure in the archive file (meaning that if you specify "/home/username/dir1", when unpacking it will create a "home" in the current directory, a "username" beneath that, a "dir1" beneath that, etc.
If you want to duplicate the behavior of "cd /home/username; tar cvf new.tar dir1 dir2" you'll need to use the "-C" option:
Code:
tar -cvf new.tar -C /home/username dir1 dir2
2. The "-C" option will handle this situation as well:
Code:
tar -xvf new.tar -C /home/username/otherdir
will extract the contents of "new.tar" into the directory "/home/username/otherdir".
3. You need to explicitly tell it which files to untar via the "-f" option (as well as specifying "x" to extract files from that archive). You *can* untar multiple files using the "-M" option and multiple "-f" declarations, but not using wildcards
Code:
tar -xvM -f file1.tar -f file2.tar
.
Alternately, you can use "find" as a front end:
Code:
find test -name "file?.tar" -exec tar -xvf {} \;
Lloyd B.
Bookmarks