[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
- <!--x-content-type: text/plain -->
- <!--x-date: Sun Aug 8 16:19:13 2004 -->
- <!--x-from-r13: puevfgbcure ng oretreba.pbz (Quevfgbcure Pretreba) -->
- <!--x-message-id: [email protected] -->
- <!--x-reference: [email protected] --> "http://www.w3.org/TR/html4/loose.dtd">
- <!--x-subject: [ale] Q: Bash: test for existence of any file matching a glib pattern. -->
- <li><em>date</em>: Sun Aug 8 16:19:13 2004</li>
- <li><em>from</em>: christopher at bergeron.com (Christopher Bergeron)</li>
- <li><em>in-reply-to</em>: <[email protected]></li>
- <li><em>references</em>: <[email protected]></li>
- <li><em>subject</em>: [ale] Q: Bash: test for existence of any file matching a glib pattern.</li>
for f in `\ls *.h`; do echo "doing something to $f; done
(backtick backslash ls star period h backtick)
Best regards,
CB
Joe Knapka wrote:
>Hi folks,
>
>A simple Bash question that google, the Bash FAQ, and the
>comp.unix.shell FAQ have failed to answer. (Possibly man bash would
>answer it, but I find I usually fall asleep before finding the
>particular tidbit I'm looking for in that horrendously gigantic
>manpage. Plus I expect there are folks on this list who do this
>kind of thing six times before breakfast.)
>
>I need to do this:
>
>if (any file matching *.h exists); then do something; fi
>
>The "any file matching *.h" test is defeating me. No variety of "[ -e
>... ]" seems to work (quoting the "*.h" different ways, and so
>forth). I've also tried
>
>for f in *.h ; do something to $f ; done
>
>That works except when there are *not* any *.h files, in which case it
>binds f to the literal string "*.h" instead, which causes bad stuff to
>happen in the "do something to $f" part. Since I'm doing this inside
>of a generic rule in a common make file for a development tree, I
>really need the command to work properly even in directories that
>don't contain any *.h files (in which case it should simply do
>nothing, not cause an error condition).
>
>Any assistance is appreciated.
>
>Thanks,
>
>-- Joe
>
>
>
</pre>
<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<hr>
<ul><li><strong>Follow-Ups</strong>:
<ul>
<li><strong><a name="00220" href="msg00220.html">[ale] Q: Bash: test for existence of any file matching a glob pattern.</a></strong>
<ul><li><em>From:</em> jknapka at kneuro.net (Joe Knapka)</li></ul></li>
</ul></li></ul>
<!--X-Follow-Ups-End-->
<!--X-References-->
<ul><li><strong>References</strong>:
<ul>
<li><strong><a name="00215" href="msg00215.html">[ale] Q: Bash: test for existence of any file matching a glib pattern.</a></strong>
<ul><li><em>From:</em> jknapka at kneuro.net (Joe Knapka)</li></ul></li>
</ul></li></ul>
<!--X-References-End-->
<!--X-BotPNI-->
<ul>
<li>Prev by Date:
<strong><a href="msg00216.html">[ale] Re: Q: Bash: test for existence of any file matching a glib pattern.</a></strong>
</li>
<li>Next by Date:
<strong><a href="msg00218.html">[ale] Q: Bash: test for existence of any file matching a glib pattern.</a></strong>
</li>
<li>Previous by thread:
<strong><a href="msg00216.html">[ale] Re: Q: Bash: test for existence of any file matching a glib pattern.</a></strong>
</li>
<li>Next by thread:
<strong><a href="msg00220.html">[ale] Q: Bash: test for existence of any file matching a glob pattern.</a></strong>
</li>
<li>Index(es):
<ul>
<li><a href="maillist.html#00217"><strong>Date</strong></a></li>
<li><a href="threads.html#00217"><strong>Thread</strong></a></li>
</ul>
</li>
</ul>
<!--X-BotPNI-End-->
<!--X-User-Footer-->
<!--X-User-Footer-End-->
</body>
</html>