0

This might be a duplicate question but I could not find any reference to my problem anywhere. I have the following structure:

DirA
 - DirB
 - DirC
 - FileX

I want an archive with this structure:

Arch.tar
 - DirB
 - DirC
 - FileX

I am running this command : tar -czvf Arch.tar -C DirA DirB DirC FileX. But I cannot figure out why tar zips it like the following structure:

Arch.tar
 - Arch
  - DirB
  - DirC
  - FileX

Any suggestions or inputs?

doa4321
  • 176
  • 2
  • 9
  • I just tried it with both GNU tar and BSD tar and it did exactly what you wanted. By the way, if you use the `z` option, the archive name should end with `.tar.gz`. – Mark Adler Apr 28 '23 at 10:07
  • I am using Windows. Is there any reason why it behaves separately from Linux systems? Also, I am not really concerned with the extension because it is a custom extension anyway, and it would ultimately be unarchived/extracted by a tool. All that matters to me is creating the archive with the correct folder structure. – doa4321 May 02 '23 at 12:54
  • I just tried exactly your directory structure and command in Windows using the BSD tar that currently comes as part of Windows. Again, it did exactly what you wanted. What tar are you using? You can try `tar --version` to see what it is. – Mark Adler May 02 '23 at 14:08
  • `bsdtar 3.5.2 - libarchive 3.5.2 zlib/1.2.5.f-ipp` - This is the result of `tar --version`. Also, I am using `7-zip` to verify the folder structure. Does that make any difference? – doa4321 May 03 '23 at 14:13
  • Quite possibly. Use tar to see what's in the tar file. `tar -tvf Arch.tar.gz`. – Mark Adler May 03 '23 at 22:42

0 Answers0