3

I have a tar.gz file that has the following structure when I extract. /dir1/dir2/dir3/many_text_files(.txt)

I would like to change the structure as dir3/many_text_files(.txt)

A simple solution is to extract it and archive again using the -C option.

But, I am wondering if there is any elegant way to do this without extracting and archiving

santhosh
  • 133

1 Answers1

2

Several solutions here, but to modify it you need to gunzip it first. The suggested hack is nice.

In your case, I'd just extract files disregarding dir structure, all into a new dir3 (if I understand correctly what's in your tarball)

SΛLVΘ
  • 1,465