Description

I can run the following command to extract the tar.gz file to 'somedir' directory, But this command requires that the directory already exists.

tar -xvf somefile.tar.gz -C somedir

Solution

Following command can extract the somefile.tar.gz file to a directory that does not exist.

tar -xf somefile.tar.gz --one-top-level=somedir