I'm creating a .tar.xz archive like this:

XZ_DEFAULTS="T$(nproc)" tar cvfJ "$archive" -C "$dir" .

It's creating this useless . directory when I try to open the archive:

How can I fix that?


This seems to work:

(shopt -s dotglob && cd "$dir" && XZ_DEFAULTS="--threads=0" tar cvfJ "$archive" *)

(Improved with Freddy's suggestion)

It's a little annoying because $archive has to be an absolute path or relative to $dir now and * doesn't generally include dot files, but I can work around that at least.

  • 1
    Enable dotglob if you use bash and want to include hidden files: (shopt -s dotglob; cd "$dir"; XZ_DEFAULTS="T$(nproc)" tar cvfJ "$archive" *) – Freddy Jun 15 '20 at 1:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.