GNU tar allows to extract the contents of an archive to a directory named after the basename of the archive.
$ touch foobar $ gnutar czf archive.tar.gz foobar $ gnutar --one-top-level -xf archive.tar.gz $ ls archive/foobar archive/foobar I can get the same result with BSD tar by running multiple commands.
$ destdir=$(basename archive.tar.gz .tar.gz) $ mkdir $destdir $ bsdtar -C $destdir -xf archive.tar.gz $ ls archive/foobar archive/foobar I would however like to run a single command just as with GNU tar. One could of course wrap the commands into shell script or shell function but I'm wondering if there is some builtin of BSD tar that produces the same result thus requiring only a single command?
Background: I would like to use BSD tar because GNU tar currently does not seem to support extended attributes on non-Linux plattforms, at least GNU tar installed via Homebrew on macOS is currently not compiled with extended attributes support.