I have the following bash script:
tar -zxvf $1
cd $1
It should extract the archive file and enter the directory that was created. Typically, package archive file creates directory with the same name, as the file, without extension, for example, mpc-1.0.1.tar.gz creates mpc-1.0.1 directory. How can I change the line cd $1
to get directory name? Archive files have several extensions: tar.gz, tat.xz, tar.bz2.