3

I have a tar.gz file, specifically: http://download.oracle.com/otn-pub/java/jdk/8u20-b26/jdk-8u20-linux-x64.tar.gz. I am going to download this, change it and stick it in my own repository.

I wish to change the name of the root directory that gets extracted without actually extracting, changing, then compressing again manually in separate commands. This is so that anyone that extracts it in the future, will have my specified folder name.

I know I can use the --transform option but that is NOT what I want, I don't want my users to have to specify this option.

Is this possible?

If not, is there a one liner that does the extraction, change and compression in such a way that doesn't change the permissions or structure etc...

4
  • download && extract && mv folder_old folder_new? Can you describe the usecase?
    – Jan
    Commented Sep 15, 2014 at 15:59
  • @Jan - its going in my own repository, I don't want the user to have to go through any extra steps to change it, I want them to be able to simply extract it and the folder name be correct.
    – Cheetah
    Commented Sep 15, 2014 at 16:07
  • if you're going to put it into you repo, then why don't you extract, change, repack and then put it into your repo?
    – Jan
    Commented Sep 15, 2014 at 16:10
  • 1
    it's not possible to change .tar (the archive) before uncompressing it Commented Sep 15, 2014 at 16:29

1 Answer 1

1

Here's your one liner, RUN AS ROOT or with sudo to preserve permissions, etc.

gunzip -c jdk-8u20-linux-x64.tar.gz | tar --transform=EXPRESSION xf - ; tar cf fixed.tar DIRNAME ; gzip fixed.tar

Sorry I can't help you on what you want the EXPRESSION/DIRNAME to be, just not enough info in the question to be able to help there.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .