tar_usage
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
tar_usage [2020/12/04 15:47] – raju | tar_usage [2020/12/04 16:00] – raju | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | === relative file names in the archive | + | ==== internal links ==== |
- | ==== Problem | + | * [[Relative file names in a tar archive]] |
- | If we tar the following directory | + | |
- | < | + | |
- | % tree --charset=unicode /tmp/expt | + | |
- | /tmp/expt | + | |
- | `-- insurance | + | |
- | |-- auto.txt | + | |
- | |-- condo.txt | + | |
- | `-- rv.txt | + | |
- | 1 directory, 3 files | ||
- | </ | ||
- | using | ||
- | < | ||
- | % tar czvf insurance.tgz / | ||
- | tar: Removing leading `/' from member names | ||
- | / | ||
- | / | ||
- | / | ||
- | / | ||
- | </ | ||
- | then the file names in the .tgz contain the whole path releative to '/' | ||
- | < | ||
- | % tar tzvf insurance.tgz | ||
- | drwxr-xr-x rajulocal/ | ||
- | -rw-r--r-- rajulocal/ | ||
- | -rw-r--r-- rajulocal/ | ||
- | -rw-r--r-- rajulocal/ | ||
- | </ | ||
- | But I want the paths to be relative to the ' | ||
- | < | ||
- | drwxr-xr-x rajulocal/ | ||
- | -rw-r--r-- rajulocal/ | ||
- | -rw-r--r-- rajulocal/ | ||
- | -rw-r--r-- rajulocal/ | ||
- | </ | ||
- | ==== Solution ==== | ||
- | Use the -C option while creating the tar archive. | ||
- | < | ||
- | % tar czvf insurance2.tgz -C /tmp/expt insurance | ||
- | insurance/ | ||
- | insurance/ | ||
- | insurance/ | ||
- | insurance/ | ||
- | </ | ||
- | Test the archive. | ||
- | < | ||
- | % tar tzvf insurance2.tgz | ||
- | drwxr-xr-x rajulocal/ | ||
- | -rw-r--r-- rajulocal/ | ||
- | -rw-r--r-- rajulocal/ | ||
- | -rw-r--r-- rajulocal/ | ||
- | </ | ||
- | ==== How it works ==== | ||
- | From the man page | ||
- | < | ||
- | % man tar | ||
- | ... | ||
- | -C, --directory=DIR | ||
- | Change | ||
- | options that follow. | ||
- | </ | ||
- | ==== System information ==== | ||
- | Debian Buster | ||
- | < | ||
- | % tar --version | ||
- | tar (GNU tar) 1.30 | ||
- | </ |
tar_usage.txt · Last modified: 2023/01/26 21:24 by raju