<div dir="ltr">The wildcard isn't being expanded by the shell because it's attached to the --directory=. The shell tries to expand --directory=/etc/systemd/mailman* and there's nothing that begins with --directory= in the current directory. Shell doesn't know it's a parameter and the file glob is after the = sign. It presumes the entire string is a file glob.<br><br>You can experiment with this using echo --directory=/etc/system/mailman* and see it's not expanding it. However echo /etc/systemd/mailman* would expand. <br>Now keep this in mind. If it does expand to more than one filename it will break the tar command. It would expand to something like<br><br>tar --directory=/etc/systemd/mailman3.service /etc/systemd/mailman3.web.service<div><br></div><div>or if you could quote it, it would be:</div><div><br></div><div>tar --directory="/etc/systemd/mailman.3.service /etc/systemd/mailman3-web.service"</div><div><br></div><div>And it would fail because there's not directory of that (combined) name.<br><div><br></div><div>And that second file name would be a separate parameter. I think only one --directory makes sense so you wouldn't want to tha/etc/t anyway. It's two commands if you want.</div><div><br></div><div>But let's say you actually wanted to expand that and pass it to command. You could expand it outside like this:<br><br>FNAME=/etc/systemd/mailman3* tar --directory="$FNAME" ...</div><div><br></div><div>Or you could:<br><br>tar --directory=$(echo /etc/systemd/mailman3*)</div><div><br></div><div>or even:<br><br>tar --directory="$(echo /etc/systemd/mailman3*)"</div><div><br></div><div>But again, that will certainly not do what you want it to.<br><br>So what do you want to do? You want to backup each directory separately? Then try this:<br><br>tar --directory=/etc/systemd/mailman3.service -cf mailman3.tar</div><div>tar --directory=/etc/systemd/mailman3-web.service -cf mailman3-web.tar</div><div><br></div><div>of if you don't know what directories exist you'd have to loop<br><br></div><div>for dir in /etc/systemd/mailman3*; do</div><div> base=$(basename "$dir")</div><div> tar --directory="$dir" -cf "${base}.tar"</div><div>done</div><div><br> Or do you want to backup both in the same Tar file:</div><div><br></div><div>tar --directory=/etc/systemd -cf mailman3.tar mailman3*</div><div><br></div><div>I've not used --directory before. I had to look it up. I grew up with SCO and HP-UX so I used:<br><br>(cd /etc/systemd && tar -cvf - mailman3*) > mailman3.tar</div><div><br></div><div>In case you're wondering it means:<br> ( - start a subshell</div><div> cd /etc/systemd - Change to that directory</div><div> && - If successful, then run the following command </div><div> tar - do the tar thing, the -f - means output to STDOUT</div><div> ) end of shell</div><div> > - Redirect output to the file using the current shell (meaning not in the changed-to direcotry</div><div><br></div><div>It seems to me the --directory method is easier.</div></div></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Wed, Jun 4, 2025 at 2:01\u202fPM Ronald Barnes via kwlug-disc <<a href="mailto:kwlug-disc@kwlug.org">kwlug-disc@kwlug.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Anton Avramov wrote on 2025-06-04 10:43:<br>
<br>
> to pass the wildcard to tar us single quotes like so:<br>
> 'etc/systemd/system/mailm*'<br>
> <br>
> Give it a go let us know<br>
<br>
# tar -vvvcf ffs.tar --directory=/ 'etc/systemd/system/mailman*'<br>
tar: etc/systemd/system/mailman*: Cannot stat: No such file or directory<br>
tar: Exiting with failure status due to previous errors<br>
<br>
<br>
Single or double quotes are giving me the same results.<br>
<br>
<br>
There's gotta be a way to do this without using `cd /` first!<br>
<br>
<br>
I've even tried "escaping" the wildcard:<br>
<br>
# tar -vvvcf ffs.tar --directory=/ 'etc/systemd/system/mailman\*'<br>
tar: etc/systemd/system/mailman\\*: Cannot stat: No such file or directory<br>
tar: Exiting with failure status due to previous errors<br>
<br>
<br>
<br>
(Thanks for the suggestion Anton!)<br>
<br>
<br>
_______________________________________________<br>
kwlug-disc mailing list<br>
To unsubscribe, send an email to <a href="mailto:kwlug-disc-leave@kwlug.org" target="_blank">kwlug-disc-leave@kwlug.org</a><br>
with the subject "unsubscribe", or email<br>
<a href="mailto:kwlug-disc-owner@kwlug.org" target="_blank">kwlug-disc-owner@kwlug.org</a> to contact a human being.<br>
</blockquote></div><div><br clear="all"></div><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div>John Van Ostrand<br></div><div>At large on sabbatical<br></div><br></div></div>