I want to download a file, untar it and rename the folder.
I am able to download the file and untar it with
curl https://s3.amazonaws.com/sampletest/sample.tar.gz | tar xz
How can I rename the folder in the same command?
curl https://s3.amazonaws.com/sampletest/sample.tar.gz | tar xz | mv ???????
I do not want to use the folder name explicitly in the command.
It's possible, but not trivial. It's easier to create your own directory, cd into it, then pass
--strip-components 1
or--strip-path 1
totar
if your tar (e.g. GNU Tar) supports it.If your system hasn't GNU
tar
installed, it might still havepax
(a POSIX tool) available. The latter supports the-s
option which allows arbitrary changes in the path name of the processed files.That would then be: