On Mon, Jul 02, 2001 at 05:07:46PM +1000, Alister Waller
([EMAIL PROTECTED]) wrote:
> Hi,
>
> just a quicky if someone could help.
>
> how do I check that a file with a particular extension exists in a directory
> in a shell script.
>
> eg:
>
> if [[ -e *.TXT ]] ; then
That depends what you want to do within that block.
You could use
find -name "*.txt" -exec STH_TO_DO {} \;
If find doesnt find anything it will not execute....
> Using a wildcard does not appear to work.
I think thats because *.txt is expanded (uner the shell) to a number of
files and hence the evaluation is incorrect:
if [[ -e one.TXT two.TXT three.TXT ]] ; then
jobst
--
Programmer - an organism that turns coffee into software !
| __, Jobst Schmalenbach, [EMAIL PROTECTED], Technical Director|
| _ _.--'-n_/ Barrett Consulting Group P/L & The Meditation Room P/L |
|-(_)------(_)= +61 3 9532 7677, POBox 277, Caulfield South, 3162, Australia|
--
SLUG - Sydney Linux User Group Mailing List - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug