I download a tarball containing only one directory; this directory has a very long name.

I desire to change that directory's name once I extract it from the tarball but I prefer another way than `mkdir` with `strip-components 1` and `-C`. 

I consider `mv` but I prefer to automatically hold the directory's name in a variable in advance;  

I thought command substitution might help by holding output **in the form of** directory name but I can't see how it can be selective only for a name (or of any particular directory) in the tarball.

How is it possible with command substitution or if not, what alternative is possible?
['https://unix.stackexchange.com/questions/536207', 'https://unix.stackexchange.com', 'https://unix.stackexchange.com/users/-1/']
I'm not sure if I understood your question correctly but I think
you're looking for something like this:

```
$ dir="$(tar tf archive.tar | cut -d / -f1 | uniq)"
$ echo "$dir"
tar-very-long-nime-very-very-long

```
With GNU tar you can use a sed-like expression to transform the file names:

```
tar -xf archive.tar.gz --xform='s,^very_long_name,short,'

```

Read about the whole thing [here](https://www.gnu.org/software/tar/manual/tar.html#SEC115).