[comp.os.minix] find / -name termcap*

sme@computing-maths.cardiff.ac.uk (Simon Elliott) (02/28/89)

In article <9096@louie.udel.EDU>, jnall%FSU.BITNET@cunyvm.cuny.edu (John Nall 904-644-5241) writes:
> ) why does find / -name termcap* -print not find /etc/termcap?  (It will
> find /usr/junk/termcap.sh, so apparently the * keeps it from finding just
> plain old termcap).

Remember that file 'globbing' (wildcard expansion) is done by the shell, in
the present working directory.  I can only assume that termcap* expands
to termcap.sh because you have a termcap.sh file in the working dir when you
issued your 'find' command.

perhaps this will make it clear:

$ ls termcap*		(this behaves as expected)
termcap.junk
termcap.sh
$ echo termcap*		(the shell expands termcap*, resulting in
			'echo termcap.junk termcap.sh'; this is dutifully done)
termcap.junk termcap.sh
$

So even 'ls termcap*' gets expanded - the file lookup is done by the shell,
and then over again by 'ls'.  In fact 'ls' knows nothing about the wildcard
convention, just like all the other /bin utilities.  This has benefits in that
wildcard expansion is done consistently; try dir t*, type t*, and del t* on
MS-DOS to see what i'm talking about.  There is a down side too - it is
difficult to guard against 'rm t *' (oops, really should have typed 'rm t*'),
for instance: many systems will ask 'Are you sure', but since 'rm' just
gets handed a list of individual filenames, how does it know you've told it
to remove everything?
-- 
--------------------------------------------------------------------------
Simon Elliott            Internet: sme%v1.cm.cf.ac.uk@cunyvm.cuny.edu
UWCC Computer Centre     JANET:    sme@uk.ac.cf.cm.v1
40/41 Park Place         UUCP:     {backbones}!mcvax!ukc!reading!cf-cm!sme
Cardiff, Wales           PHONE:    +44 222 874300