[ale] Q: Bash: test for existence of any file matching a glib pattern.
Geoffrey
esoteric at 3times25.net
Sun Aug 8 16:23:07 EDT 2004
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 above won't work as it will expand the *.h before the test and
you'll get a syntax error.
Here's a quick possibilitie:
ls *.h >/dev/null 2>/dev/null && dothis
dothis will be executed if there are any files that match the pattern.
Send stdout and stderr to /dev/null as you're not interested in any
error or output.
--
Until later, Geoffrey Registered Linux User #108567
AT&T Certified UNIX System Programmer - 1995
More information about the Ale
mailing list