tar_usage
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
tar_usage [2020/12/04 15:47] – raju | tar_usage [2023/01/26 21:24] (current) – [sample commands] raju | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | === relative | + | ==== count number of lines in a txz file ==== |
- | ==== Problem | + | |
- | If we tar the following directory | + | |
< | < | ||
- | % tree --charset=unicode /tmp/expt | + | xz -cd foo.txz | wc -l |
- | /tmp/expt | + | |
- | `-- insurance | + | |
- | |-- auto.txt | + | |
- | | + | |
- | `-- rv.txt | + | |
- | + | ||
- | 1 directory, 3 files | + | |
</ | </ | ||
- | using | + | |
< | < | ||
- | % tar czvf insurance.tgz / | + | for i in *.txz; do echo $i; xz -cd $i | wc; done |
- | tar: Removing leading `/' from member names | + | |
- | / | + | |
- | / | + | |
- | / | + | |
- | / | + | |
</ | </ | ||
- | then the file names in the .tgz contain the whole path releative to '/' | + | |
+ | ==== file extensions ==== | ||
+ | * tar gzip compressed - .tgz | ||
+ | * tar bzip2 compressed - .tar.bz2, .tar.bz, .tbz | ||
+ | * tar xz compressed - .txz | ||
+ | |||
+ | ==== sample commands ==== | ||
< | < | ||
- | % tar tzvf insurance.tgz | + | tar cJvf foo.txz foo |
- | 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 | + | ==== convert tgz to txz ==== |
- | Use the -C option while creating the tar archive. | + | |
< | < | ||
- | % tar czvf insurance2.tgz -C /tmp/expt insurance | + | cat foo.tgz | gzip -cd | xz > foo.txz |
- | insurance/ | + | |
- | insurance/ | + | |
- | insurance/ | + | |
- | insurance/ | + | |
- | </code> | + | |
- | 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 ==== | + | To do the other way around |
- | Debian Buster | + | |
< | < | ||
- | % tar --version | + | cat foo.txz | xz -cd | gzip > foo.tgz |
- | tar (GNU tar) 1.30 | + | |
</ | </ | ||
+ | |||
+ | Ref:- http:// | ||
+ | |||
+ | tags | change compression algorithm of a tar archive | ||
+ | |||
+ | ==== internal links ==== | ||
+ | * [[Relative file names in a tar archive]] | ||
+ | |||
+ | |||
+ |
tar_usage.1607096830.txt.gz · Last modified: 2020/12/04 15:47 by raju