Directory – How to Create Target Directory When Extracting Tarball

directorytar

Is it possible to create a target directory, similar to mkdir -p, where I can define a non-existent target directory within my tar command, and tar will create the directory for me?

I know I can redirect the output to a directory using tar -C /target/dir, but this doesn't work if the target directory is non-existent.

Best Answer

mkdir -p /target/dir && tar -C /target/dir
Related Question