On Tuesday 03 April 2007, Ross Drummond wrote:
> On Tue, 03 Apr 2007 05:29, Roger Searle wrote:>
>
> > stuff about extracting tar files.
> > bla bla bla
>
> A related question.
>
> How do I extract a named file from a tar archive and place it in the
> current directory without the file path appended to the file.?
man tar he say:-
--strip-components NUMBER, --strip-path NUMBER
strip NUMBER of leading components from file names
before extraction
(1) tar-1.14 uses --strip-path,
tar-1.14.90+ uses --strip-components
e.g.
[EMAIL PROTECTED] ~/tmp $ mkdir -p one/two/three/
[EMAIL PROTECTED] ~/tmp $ touch one/two/three/file.ext
[EMAIL PROTECTED] ~/tmp $ tar cvf example.tar one
one/
one/two/
one/two/three/
one/two/three/file.ext
[EMAIL PROTECTED] ~/tmp $ tar tvf example.tar one
drwxr-xr-x chris/users 0 2007-04-03 11:13 one/
drwxr-xr-x chris/users 0 2007-04-03 11:13 one/two/
drwxr-xr-x chris/users 0 2007-04-03 11:14 one/two/three/
-rw-r--r-- chris/users 0 2007-04-03 11:14 one/two/three/file.ext
[EMAIL PROTECTED] ~/tmp $ tar xv --strip-components 3 -f example.tar \
one/two/three/file.ext
[EMAIL PROTECTED] ~/tmp $ ls -l
total 16
-rw-r--r-- 1 chris users 10240 Apr 3 11:14 example.tar
-rw-r--r-- 1 chris users 0 Apr 3 11:14 file.ext
--
CS