[kwlug-disc] tar --directory help please

Anton Avramov lukav at lukav.com
Wed Jun 4 13:43:43 EDT 2025


When you run with etc/systemd/system/mailm* the shell is trying to
expand this to existing files. The error you are seeing is from the
shell and not tar. 

to pass the wildcard to tar us single quotes like so:
'etc/systemd/system/mailm*' 

Give it a go let us know

On Wed, 2025-06-04 at 10:33 -0700, Ronald Barnes via kwlug-disc wrote:
> 
> I've always found the --directory option for `tar` to be so
> frustrating 
> as to be worse than useless.
> 
> 
> Can someone explain this behaviour?
> 
> 
> There are 2 files I want to include:
> 
> # ll /etc/systemd/system/mailman*
> -rw-r--r-- 1 mailman root  461 2025-05-31 07:00 
> /etc/systemd/system/mailman3.service
> -rw-r--r-- 1 mailman root 1226 2025-06-04 06:35 
> /etc/systemd/system/mailman3-web.service
> 
> 
> However... errors with or without quotes around the path to archive:
> 
> # tar -vcf ffs.tar --directory=/ etc/systemd/system/mailm*
> tar: etc/systemd/system/mailm*: Cannot stat: No such file or
> directory
> tar: Exiting with failure status due to previous errors
> 
> 
> 
> If I exclude the wildcard:
> 
> # tar -vcf ffs.tar --directory=/ etc/systemd/system/
> etc/systemd/system/
> etc/systemd/system/network-online.target.wants/
> etc/systemd/system/network-online.target.wants/networking.service
> etc/systemd/system/mailman3.service
> ...
> 
> 
> And the last file shown is one of the target files.
> 
> 
> 
> What is going on?!?
> 
> This has driven me absolutely bonkers for years and I'm determined to
> figure it out.
> 
> ChatGPT struggles with it, and I can't even blame it.
> 
> 
> _______________________________________________
> kwlug-disc mailing list
> To unsubscribe, send an email to kwlug-disc-leave at kwlug.org
> with the subject "unsubscribe", or email
> kwlug-disc-owner at kwlug.org to contact a human being.



More information about the kwlug-disc mailing list