|
Removing leading directory from tar.bz2 archive.
Suppose you have a directory named 'test' containing another directory
'openldap-2.3.27'
and.
[root@localhost ~]# cp -r /usr/share/doc/openldap-2.3.27/ test
Changed user permissions, (to demonstrate file permissions are not changed)
[root@localhost ~]# chown -R rakesh.rakesh test -v
Created a tar.bz2 compressed file.
[root@localhost ~]# tar cjvpf test1.tar.bz2 test
Uncompressing with available parameters of tar command.
[root@localhost ~]#tar xjvp --stripe-components 1 -f test1.tar.bz2 -C /tmp/
Here --stripe-components 1 will cause to filter out first leading directory, in
our case
'test' directory. -C parameter is used to define destination directory and 'p'
parameter
causes to preserve file permissions.
[root@localhost ~]# ls -l /tmp
total 32
drwx------ 2 root root 16384 Jan 6 2008 lost+found
srwxrwxr-x 1 anuj anuj 0 Jan 6 2008 mapping-anuj
srwxr-xr-x 1 root root 0 Jan 1 17:24 mapping-root
drwxr-xr-x 2 rakesh rakesh 4096 Jan 4 09:39 openldap-2.3.27
Leading 'test' directory is stripped out, user permissions are unchanged after
decompression of test1.tar.bz2 file
Anuj.
|