Can files in gzipped tarballs be extracted without paths?
Walter Dnes
waltdnes-SLHPyeZ9y/tg9hUCZPvPmw at public.gmane.org
Fri Aug 1 03:20:43 UTC 2014
On Wed, Jul 30, 2014 at 09:27:55PM -0400, Jamon Camisso wrote
> On 2014-07-30 9:05 PM, Walter Dnes wrote:
> > Situation;
> > * I download a *.tar.gz file
> > * I know that it has a tarred subdirectory containing a bunch of files
> > * I want the files in the subdirectory extracted directly to the current
> > directory.
> >
> > E.g. if the tarball has subdirectory foo with files foo/file1,
> > foo/file2 foo/file2, etc, I want to be able to extract file1, file2, and
> > file3 directly. Right now, I dive into the tarball with mc (Midnight
> > Commander), and "mark and copy" the files in the virtual file system.
> > unzip has the -j option to "junk" the directorie structure, and unzip
> > all files in the archive into one directory. Is something similar
> > available with tar?
>
> Try using --strip-components. You'd want to strip 1 leading component to
> get all the files into your cwd.
>
> If you want tar to extract to a directory you can use -C, for example:
>
> tar xvzf your-tar-file.tar.gz --strip-components=1 -C /tmp/bar foo
>
> You'd end up with file1, file2, file3 in /tmp/bar based on specifying
> you only want to extract the foo directory, and that you want to strip
> the first component of the path of the extracted file/directory.
Thanks. That's what I was looking for. Let's just say that the tar
man page is "rather terse".
--
Walter Dnes <waltdnes-SLHPyeZ9y/tg9hUCZPvPmw at public.gmane.org>
I don't run "desktop environments"; I run useful applications
--
The Toronto Linux Users Group. Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists
More information about the Legacy
mailing list