[kwlug-disc] tar --directory help please

William Park opengeometry at yahoo.ca
Thu Jun 5 11:47:34 EDT 2025


I was going to suggest this, but okay.  Then, your only choice is
use subshell (cd / && tar ...) or pushd/popd which is the same thing.

On 2025-06-04 15:36, Ronald Barnes via kwlug-disc wrote:
>> All that said, it looks like in your example, you're trying to 
>> preserve the full path (hence --directory=/).  You don't need to use 
>> --directory for that. Just provide the full path to the files, that 
>> will be preserved in the zip.
>>
>>      $ tar -cf /tmp/test.tar /etc/systemd/system/mailm*
> 
> This causes the mildly annoying warning:
> 
> tar: Removing leading `/' from member names
> 
> Which, in cron jobs, generates emails.
> 
> Redirecting errors / warnings to /dev/null isn't ideal in such situations.
> 
> 
> 
> I now feel like I should make an effort to use pushd and popd on at 
> least some occasions.
> 
> Bonus is, I'd probably make the typo I just made (and corrected): `poopd`.
> 
> 
> _______________________________________________
> 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