<div dir="ltr">The wildcard isn&#39;t being expanded by the shell because it&#39;s attached to the --directory=. The shell tries to expand --directory=/etc/systemd/mailman* and there&#39;s nothing that begins with --directory= in the current directory. Shell doesn&#39;t know it&#39;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&#39;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=&quot;/etc/systemd/mailman.3.service /etc/systemd/mailman3-web.service&quot;</div><div><br></div><div>And it would fail because there&#39;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&#39;t want to tha/etc/t anyway. It&#39;s two commands if you want.</div><div><br></div><div>But let&#39;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=&quot;$FNAME&quot; ...</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=&quot;$(echo /etc/systemd/mailman3*)&quot;</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&#39;t know what directories exist you&#39;d have to loop<br><br></div><div>for dir in /etc/systemd/mailman3*; do</div><div>  base=$(basename &quot;$dir&quot;)</div><div>  tar --directory=&quot;$dir&quot; -cf &quot;${base}.tar&quot;</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&#39;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 &amp;&amp; tar -cvf - mailman3*) &gt; mailman3.tar</div><div><br></div><div>In case you&#39;re wondering it means:<br>  ( - start a subshell</div><div> cd /etc/systemd  - Change to that directory</div><div>  &amp;&amp; - 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>  &gt; - 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 &lt;<a href="mailto:kwlug-disc@kwlug.org">kwlug-disc@kwlug.org</a>&gt; 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>
&gt; to pass the wildcard to tar us single quotes like so:<br>
&gt; &#39;etc/systemd/system/mailm*&#39;<br>
&gt; <br>
&gt; Give it a go let us know<br>
<br>
# tar -vvvcf ffs.tar --directory=/ &#39;etc/systemd/system/mailman*&#39;<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&#39;s gotta be a way to do this without using `cd /` first!<br>
<br>
<br>
I&#39;ve even tried &quot;escaping&quot; the wildcard:<br>
<br>
# tar -vvvcf ffs.tar --directory=/ &#39;etc/systemd/system/mailman\*&#39;<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 &quot;unsubscribe&quot;, 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>