Skip to main content
use absolute paths for multiple -C, because the second -C is relative to the first one; archive `.`, not the list of files in the current directory
Source Link
Gilles 'SO- stop being evil'
  • 865.4k
  • 205
  • 1.8k
  • 2.3k

I think you can do this with the -C option.

From the tar man page:

-C directory, --cd directory, --directory directory
    In c and r mode, this changes the directory before adding the following files.
    In x mode, change directories after opening the archive but before extracting
    entries from the archive.

This means that you should be able to run

tar cvzf result.tar.gz -C dir1/ * -C dir2/ *

tar cvzf result.tar.gz -C /path/to/dir1/ . -C /path/to/dir2/ .

to achieve what you want.

I think you can do this with the -C option.

From the tar man page:

-C directory, --cd directory, --directory directory
    In c and r mode, this changes the directory before adding the following files.
    In x mode, change directories after opening the archive but before extracting
    entries from the archive.

This means that you should be able to run

tar cvzf result.tar.gz -C dir1/ * -C dir2/ *

to achieve what you want.

I think you can do this with the -C option.

From the tar man page:

-C directory, --cd directory, --directory directory
    In c and r mode, this changes the directory before adding the following files.
    In x mode, change directories after opening the archive but before extracting
    entries from the archive.

This means that you should be able to run

tar cvzf result.tar.gz -C /path/to/dir1/ . -C /path/to/dir2/ .

to achieve what you want.

Source Link
arnefm
  • 3.2k
  • 20
  • 16

I think you can do this with the -C option.

From the tar man page:

-C directory, --cd directory, --directory directory
    In c and r mode, this changes the directory before adding the following files.
    In x mode, change directories after opening the archive but before extracting
    entries from the archive.

This means that you should be able to run

tar cvzf result.tar.gz -C dir1/ * -C dir2/ *

to achieve what you want.