in reply to Re: Test for file(s): glob or -e?
in thread Test for file(s): glob or -e?

*boggles*

Why grep -e? Does glob make up stuff that doesn't exist in the directory now?

Replies are listed 'Best First'.
Re: Re: Re: Test for file(s): glob or -e?
by ysth (Canon) on Feb 18, 2004 at 18:57 UTC
    By design, glob only checks for actual existence of files if you include * or ? in that part of the path:
    $ echo hi there>foo $ ls foo $ perl -wle'print for glob "{a,b,c,}fo{*,}"' afo bfo cfo foo fo
    This pattern expands to {afo,bfo,cfo,fo,afo*,bfo*,cfo*,fo*}. Only the subpatterns containing a ? or * will be restricted to what exists. In the simple case, glob "joe.txt" will always return joe.txt.