[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-tar] TAR strip leading paths

From: Doug McLaren
Subject: Re: [Bug-tar] TAR strip leading paths
Date: Tue, 23 Jan 2007 10:44:33 -0600
User-agent: Mutt/

On Tue, Jan 23, 2007 at 01:55:08PM +0100, Tomas M wrote:

| I'd like to create a tar archive from few directories and combine them 
| to a single directory in Tar. This is a task for Tar guru I guess,


| as I 
| am unable to find the solution in documentation.
| For example, I'd like to pack
|   /usr/local/modules/*
|   /var/modules/*
| to a single Tar archive, which will only contain (this is my problem) 
| the files (and directories) from the dirs mentioned above
| combined into root, but without the leading path.
| I tried
| tar --create --file output.tar /var/modules/* /usr/local/modules/*

Try this :

   tar --create --file=output.tar -C /var/modules . -C /usr/local/modules .

       -C, --directory DIR
              change to directory DIR

The only real gotcha here is that you can't use `*' as the * is
expanded by your shell, and your shell won't know that it should be
looking in another directory after the -C/--directory options.  So
instead of using `*', use `.'

Another option (probably not as good, however), would be this --

       --strip-components NUMBER, --strip-path NUMBER
              strip  NUMBER  of  leading  components  from  file  names before

              (1) tar-1.14 uses --strip-path, tar-1.14.90+ uses --strip-compo-

but it appears to be used at extraction time, not creation time -- so
it could extract the tar file the way you want it, but the tar file
itself wouldn't be the way you want it.

Doug McLaren, address@hidden
There is always one item on the screen menu that is mislabeled and should

reply via email to

[Prev in Thread] Current Thread [Next in Thread]